In Bash is there a difference between these two variable definitions?
error=
error=''
Testing them on emptiness / being unset seems to suggest that they are equal but I still I would like to be sure.
Short answer: No, there are no differences at all. The quotes are stripped during parsing.
From the Variable Assignment section of the POSIX reference:
In the shell command language, a word consisting of the following parts:
varname=value
and a few lines below you'll see:
If value is not specified, the variable shall be given a null value.
To check this (in Bash):
$ variable1=
$ variable2=''
$ declare -p variable{1,2}
declare -- variable1=""
declare -- variable2=""
they do look identical!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With