dash unset idiosyncrasies
Parke <parke.nexus <at> gmail.com>
2015-07-06 02:18:15 GMT
The man page for dash says:
unset [-fv] name ...
The specified variables and functions are
unset and unexported. If -f or -v is speci‐
fied, the corresponding function or variable
is unset, respectively. If a given name cor‐
responds to both a variable and a function,
and no options are given, only the variable is
The man page does not say what happens if the given name corresponds
only to a function.
Based on experimentation, I have determined that in dash versions
0.5.7, 0.5.8, and git head, "unset name" (without -f) will only unset
variables and will never unset any function.
In addition, during my experiments, I discovered idiosyncrasies that
are demonstrated by the following script.
The script runs a series of tests. Each test sets a variable and
function, both named "true" (so as to overshadow /bin/true). The test
then tries to unset either the variable, or the function, or both.
The test then probes the existence of the variable and function, and
compares to the expected result.