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
?
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