When I do this, it works perfectly and downloads the file at the required path.
wget -O ~/Temp/my.file "https://github.com/sometool/releases/latest/download/the.file"
But when I do this:
PATH="~/Temp/my.file"
wget -O $PATH "https://github.com/sometool/releases/latest/download/the.file"
It says:
~/Temp/my.file: No such file or directory
I've tried with or without quotes, wrapped in $(echo $PATH), always the same error.
I am using MacOS Terminal.
~
is expanded there, so you would see the path to your home directory there, but becausePATH
is a system variable that indicates where to find commands, so the actual effect of the code you posted would bezsh: command not found: wget
. Please copy-paste what you actually typed. Preferably in a new terminal tab, since you might have done some weird reconfiguration in that shell before the part you posted. – Gilles 'SO- stop being evil' Sep 07 '21 at 15:51set -o magicequalsubst
won't make any difference? – Kulfy Sep 07 '21 at 15:53magicequalsubst
only affects equal signs that are not variable assignments.PATH=…
is a variable assignment, so an unquoted tilde at the beginning is always expanded. – Gilles 'SO- stop being evil' Sep 07 '21 at 16:25