In shell, what are the differences between a variable that is declared, defined and set?
Does "declared" mean the identifier of the variable exists, but the storage and value of the variable do not?
Does "defined" mean both the identifier and the storage of the variable exist?
Does "set" mean the value of the variable exists? (I read something about it in the section for shell variables in Bash Manual)
Do "defined" and "set" imply each other, and therefore they are the same?
In Bash manual, the section of parameter expansion mentions that
${parameter:-word}
does something whenparameter
is unset or null.Does "null" mean "declared" but not "defined", or "declared" but not "set"?
Does "unset" mean not "declared"?
Do the concepts mentioned also apply to the names of functions and mean the same as for parameters/variables?
what other similar concepts do I miss?
Note:
I am interested in answers for POSIX shell and Bash respectively.
Note that by "the value of a variable exists", I mean the the variable has been assigned a value. By "the storage of a variable exists", I mean the variable has been allocated storage in memory.
My questions came from reading https://unix.stackexchange.com/a/56846/674 and related sections in Bash manual.