dash does not parse valid POSIX arithmetic

Bug #92189 reported by Will Newton
16
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dash (Debian)
Fix Released
Unknown
dash (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: dash

This script:

cnt=6
while [ $((cnt = cnt - 1)) -gt 0 ]; do
    echo $cnt
done

Is not parsed. Expansion and assignment in shell arithmetic appear to be mandated by the POSIX standard.

http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_04

"All changes to variables in an arithmetic expression shall be in effect after the arithmetic expansion, as in the parameter expansion "${x=value}".

If the shell variable x contains a value that forms a valid integer constant, then the arithmetic expansions "$((x))" and "$(($x))" shall return the same value."

Changed in dash:
status: Unconfirmed → Confirmed
Changed in dash:
status: Unknown → Confirmed
Micah Cowan (micahcowan)
Changed in dash:
importance: Undecided → Medium
Revision history for this message
Ian! D. Allen (idallen) wrote :

Now that dash is used for /bin/sh all my #!/bin/sh shell scripts are
breaking system-wide due to the failure of dash to properly expand $((x))
the same as $(($x)) as POSIX requires. I have a massive edit job to do
to change them all to work around this dash bug. Please do consider
this an important fix (or revert Ubuntu to using bash for /bin/sh for
a while longer until you do have time to fix dash).

Revision history for this message
comotion (comotion) wrote :

I have opened a new bug for the wider set of dash incompatabilites at https://bugs.launchpad.net/ubuntu/+source/dash/+bug/141481

Changed in dash:
status: Confirmed → Fix Released
Revision history for this message
Adam Buchbinder (adam-buchbinder) wrote :

According to the Debian report, this was fixed in 0.5.4-3. Intrepid currently uses 0.5.4-9ubuntu1.1.

The script in the original report works, as does this test from the Debian report:

$ dash -c 'unset x; echo $((x=14+7)) $x'
21 21

Changed in dash:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.