I'm using Windows 11 with WSL 2 Ubuntu 18.04 as Guest OS.
I have written the following script as part of ~/.bash_profile
with the intent to set the PRELUDE_HOST
env variable both in my Ubuntu OS and on the Windows OS:
export PRELUDE_HOST=10.10.225.241
WINDOWS_PRELUDE_HOST=`cmd.exe /c echo %PRELUDE_HOST%`
if [[ "$PRELUDE_HOST" != "$WINDOWS_PRELUDE_HOST" ]]
then
cmd.exe /c setx PRELUDE_HOST $PRELUDE_HOST
fi
The first time I run this script - the PRELUDE_HOST
env is set onto the Windows OS globally.
But for some reason, if I run the script a second time - the string comparison doesn't work as expected and the cmd.exe /c setx PRELUDE_HOST $PRELUDE_HOST
runs a second time.
I can't figure out why the if [[ "$PRELUDE_HOST" != "$WINDOWS_PRELUDE_HOST" ]]
comparison is not working as expected. Any suggestions?