Ubuntu

dash does not parse valid POSIX arithmetic

Reported by Will Newton on 2007-03-14
16
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dash (Debian)
Fix Released
Unknown
dash (Ubuntu)
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) on 2007-05-16
Changed in dash:
importance: Undecided → Medium
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).

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

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  Edit
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.