Comment 6 for bug 139097

Revision history for this message
Jilles Tjoelker (jilles) wrote : Re: dash 0.5.3-5ubuntu2 variable expansion error using local

"local" will not be removed from dash, as it is used too much, even though it is not in POSIX.

The underlying problem is related to a feature in bash which also applies to some POSIX special builtins (export and readonly). This feature is not in POSIX and strictly speaking conflicts with it.

Dash expands your local y=$x to local y=1 2 3, so three parameters for local. It fails because "2" is not a valid variable name. Bash does not perform field splitting and pathname generation on words that look like assignments, if given as argument to certain builtins such as export, readonly and local, so that the command does what you want. You can write local y="$x" to do this in a portable manner. Alternatively, first make the variable local, and then assign the value.