Bash: "command not found" on simple variable assignment Bash: "command not found" on simple variable assignment bash bash

Bash: "command not found" on simple variable assignment


You can add colon:

: ${something:="false"}: ${something_else:="blahblah"}: ${name:="file.ext"}

The trick with a ":" (no-operation command) is that, nothing gets executated, but parameters gets expanded. Personally I don't like this syntax, because for people not knowing this trick the code is difficult to understand.

You can use this as an alternative:

something=${something:-"default value"}

or longer, more portable (but IMHO more readable):

[ "$something" ] || something="default value"


Putting a variable on a line by itself will execute the command stored in the variable. That an assignment is being performed at the same time is incidental.

In short, don't do that.

echo ${something:="false"}echo ${something_else:="blahblah"}echo ${name:="file.ext"}


It's simply

variable_name=value

If you use $(variable_name:=value} bash substitutes the variable_name if it is set otherwise it uses the default you specified.