Below I run what I expected to be an invalid command: var=3 date, which in fact isn't.
$ var=3 date
Sun May 26 17:10:22 UTC 2019
$ echo $?
0
But the variable wasn't assigned the value 3:
$ echo $var
$
I expected to say that var=3 wasn't a valid command. What am I missing?
man dash, seeSimple Commandssection. – Arkadiusz Drabczyk May 26 '19 at 17:49compgen -vgives us completion options of variables. Runningvar=3 compgen -vwon't displayvar. – Damn Spaces May 26 '19 at 18:03echo $varin a separate script calledtest.shand callingvar=3 ./test.sh.compgenis a builtin. Or, even better, putcompgen -vin that script and you will see var pop up. – Edward May 26 '19 at 18:18