Skip to content

Commit

Permalink
Fix chaotic chinese characters with golang cli commands
Browse files Browse the repository at this point in the history
When debugging load command, it is found that `./bin/alluxio` CLI can't process Chinese characters correctly. There must be something wrong with the CLI encoding or decoding. It seems that the Chinese characters are encoded incorrectly.

This happens because the construction of CLI commands does not initialize environmental variables correctly. OS-level environmental variables are ignored, so the program uses a false encoder.

This pull request fixes this problem.
			pr-link: #18386
			change-id: cid-a15fb106b4a6cd77087cdbba82e426f1ba1e4b4c
  • Loading branch information
twalluxio authored Nov 7, 2023
1 parent 420e560 commit 7d15de7
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions cli/src/alluxio.org/cli/env/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func (c *BaseJavaCommand) RunJavaClassCmd(args []string) *exec.Cmd {
cmdArgs = append(cmdArgs, args...)

ret := exec.Command(Env.EnvVar.GetString(ConfJava.EnvVar), cmdArgs...)
ret.Env = os.Environ()
for _, k := range Env.EnvVar.AllKeys() {
ret.Env = append(ret.Env, fmt.Sprintf("%s=%v", k, Env.EnvVar.Get(k)))
}
Expand Down

0 comments on commit 7d15de7

Please sign in to comment.