How do I set a variable in Bash Zsh with a single dash (-
)?
None of these work:
x=-
x=\-
x='-'
EDIT: this seems to work fine in Bash, I was testing this with echo in Zsh which doesn't work.
How do I set a variable in Bash Zsh with a single dash (-
)?
None of these work:
x=-
x=\-
x='-'
EDIT: this seems to work fine in Bash, I was testing this with echo in Zsh which doesn't work.
The problem was with echo. The variable is assigned correctly but had to be used with echo - $x
instead.
echo
sucks. – ilkkachu Sep 22 '21 at 22:25