The difference between error = and error = ''

In Bash, is there a difference between these two variable definitions?

error=
error=''

Testing them for void / mismatch seems to suggest that they are equal, but I still had to be sure.

+4
source share
1 answer

Short answer: No, there are no differences. Quotation marks are removed during parsing.


In the "Assigning Variables" section of a POSIX link :

In the shell command language, a word consists of the following parts:

varname=value

and a few lines below, you will see:

If no value is specified, the variable is assigned an empty value.

To check this (in Bash):

$ variable1=
$ variable2=''
$ declare -p variable{1,2}
declare -- variable1=""
declare -- variable2=""

they look the same!

+8
source

Source: https://habr.com/ru/post/1609436/


All Articles