Java command with flags runs in bash but not zsh

Abhijay Bhatnagar

I'm running into an issue where I'm able to run java with proxy settings in bash but not in zsh.

In order to run the jar, I'm first setting my proxy settings with an env variable:

export JAVA_OPTS="-Dhttp.proxyHost=my.proxy.org -Dhttp.proxyPort=80 -Dhttps.proxyHost=my.proxy.org -Dhttps.proxyPort=80 -DsocksProxyHost=my.proxy.org -DsocksProxyPort=80"

Then I run the jar with the following

java $JAVA_OPTS -jar path/to/file.jar

It runs successfully in bash, but when running through zsh, it isn't able to recognize the proxy settings and it fails when trying to establish a network connection.

Anyone know how I can resolve this to be able to use zsh?

glenn jackman

zsh does word splitting differently from bash. I think you need to be explicit that you want to split it. Consider this, which acts like a bash quoted variable

$ export JAVA_OPTS="-Dhttp.proxyHost=my.proxy.org -Dhttp.proxyPort=80 -Dhttps.proxyHost=my.proxy.org -Dhttps.proxyPort=80 -DsocksProxyHost=my.proxy.org -DsocksProxyPort=80"
$ printf ">%s<\n" $JAVA_OPTS
>-Dhttp.proxyHost=my.proxy.org -Dhttp.proxyPort=80 -Dhttps.proxyHost=my.proxy.org -Dhttps.proxyPort=80 -DsocksProxyHost=my.proxy.org -DsocksProxyPort=80<

versus this

$ printf ">%s<\n" ${=JAVA_OPTS}
>-Dhttp.proxyHost=my.proxy.org<
>-Dhttp.proxyPort=80<
>-Dhttps.proxyHost=my.proxy.org<
>-Dhttps.proxyPort=80<
>-DsocksProxyHost=my.proxy.org<
>-DsocksProxyPort=80<

See: man zshexpn

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Java command with flags runs in bash but not zsh

分類Dev

Bash script that runs a command with arguments and redirects

分類Dev

`time <command>` is different in zsh than in bash

分類Dev

run bash script doesn't work alias command in zsh

分類Dev

bash: using scp in cron job fails, but runs succesfully when run from command line

分類Dev

BASHの$ PROMPT_COMMANDに相当するZSHは何ですか?

分類Dev

`time <command>`はzshとbashで異なります

分類Dev

If I set java bin PATH Dockerfile Jar Command runs but tomcat doesn't

分類Dev

Comments in command-line Zsh

分類Dev

zsh, modifying an old command in history

分類Dev

zsh: set option for a single command

分類Dev

Replace string in command to be executed in zsh

分類Dev

How to pass flags as argument of urface/cli command?

分類Dev

Java_HOME not found when changed shell from Bash to Zsh on OSX?

分類Dev

Double and triple substitution in bash and zsh

分類Dev

A java App which runs in intelliJ But not runs in cmd

分類Dev

How to keep zsh running after command execution?

分類Dev

Add arguments from previous command to zsh completion

分類Dev

How to exclude a file from a command with ZSH?

分類Dev

Is there anything in Zsh like bash_profile?

分類Dev

Is there anything in Zsh like bash_profile?

分類Dev

the difference between a subshell and detach in bash or zsh?

分類Dev

Unable to install a python package on zsh but successful on bash

分類Dev

Definitively determine if currently running shell is bash or zsh

分類Dev

Get the expansion of an alias (in both bash and zsh)

分類Dev

Return from emulate bash unsets zsh opts

分類Dev

Handling command line options with multiple arguments for some flags

分類Dev

-bash: cfssl: command not found

分類Dev

Bash alias: command not found

Related 関連記事

  1. 1

    Java command with flags runs in bash but not zsh

  2. 2

    Bash script that runs a command with arguments and redirects

  3. 3

    `time <command>` is different in zsh than in bash

  4. 4

    run bash script doesn't work alias command in zsh

  5. 5

    bash: using scp in cron job fails, but runs succesfully when run from command line

  6. 6

    BASHの$ PROMPT_COMMANDに相当するZSHは何ですか?

  7. 7

    `time <command>`はzshとbashで異なります

  8. 8

    If I set java bin PATH Dockerfile Jar Command runs but tomcat doesn't

  9. 9

    Comments in command-line Zsh

  10. 10

    zsh, modifying an old command in history

  11. 11

    zsh: set option for a single command

  12. 12

    Replace string in command to be executed in zsh

  13. 13

    How to pass flags as argument of urface/cli command?

  14. 14

    Java_HOME not found when changed shell from Bash to Zsh on OSX?

  15. 15

    Double and triple substitution in bash and zsh

  16. 16

    A java App which runs in intelliJ But not runs in cmd

  17. 17

    How to keep zsh running after command execution?

  18. 18

    Add arguments from previous command to zsh completion

  19. 19

    How to exclude a file from a command with ZSH?

  20. 20

    Is there anything in Zsh like bash_profile?

  21. 21

    Is there anything in Zsh like bash_profile?

  22. 22

    the difference between a subshell and detach in bash or zsh?

  23. 23

    Unable to install a python package on zsh but successful on bash

  24. 24

    Definitively determine if currently running shell is bash or zsh

  25. 25

    Get the expansion of an alias (in both bash and zsh)

  26. 26

    Return from emulate bash unsets zsh opts

  27. 27

    Handling command line options with multiple arguments for some flags

  28. 28

    -bash: cfssl: command not found

  29. 29

    Bash alias: command not found

ホットタグ

アーカイブ