dash variable expansion error using local, readonly, and export
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dash (Ubuntu) |
Confirmed
|
Low
|
Unassigned |
Bug Description
<pre>
Binary package hint: dash
[Edited May 2010]
True for all dash up to at least May 2010.
Bug in variable expansion (incorrect word-splitting) using an assignment
with "local", "readonly", or "export in dash:
$ x='1 2 3'
$ y=$x # this works fine
$ echo "$y"
1 2 3
$ local y=$x # this fails due to dash bug
local: 2: bad variable name
$ echo "$y"
1
$ readonly y=$x # this fails due to dash bug
readonly: 2: bad variable name
$ export y=$x # this fails due to dash bug
export: 2: bad variable name
The same use of assignment using "local", "readonly" and "export" all work
fine in bash:
bash-3.2$ x='1 2 3'
bash-3.2$ y=$x
bash-3.2$ echo "$y"
1 2 3
bash-3.2$ local y=$x
bash: local: can only be used in a function
bash-3.2$ foo () {
> local y=$x
> echo "$y"
> }
bash-3.2$ foo
1 2 3
bash-3.2$ readonly y=$x # works fine
bash-3.2$ export y=$x # works fine
description: | updated |
description: | updated |
Changed in dash: | |
importance: | Undecided → Low |
status: | New → Confirmed |
description: | updated |
Hey! The bugs.launchpad.net bug display web page compresses whitespace.
Don't do that. I put the whitespace there to make it more readable.
Bugs should be displayed in fixed-width font with all whitespace preserved.