dash arithmetic gets & operator wrong without whitespace

Bug #296883 reported by Nathan Williams
2
Affects Status Importance Assigned to Milestone
dash (Arch Linux)
New
Undecided
Unassigned
dash (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: dash

Evaluation of arithmetic expressions such as $((255&255)) produce an incorrect result with dash.
$ /bin/dash
$ echo $((255&255))
55
$ echo $((255&127))
27

It seems to ignore the digit immediately after the & operator. With whitespace after the &, it works properly:

$ echo $((255& 255))
255
$ echo $((255& 127))
127

This proper behavior is also seen in bash (3.2-0ubuntu18), NetBSD ash (NetBSD 4.0), and dash-0.5.3-7 (Debian).

$ lsb_release -rd
Description: Ubuntu 8.04.1
Release: 8.04

$ apt-cache policy dash
dash:
  Installed: 0.5.4-8ubuntu1
  Candidate: 0.5.4-8ubuntu1
  Version table:
 *** 0.5.4-8ubuntu1 0
        500 http://us.archive.ubuntu.com hardy/main Packages
        100 /var/lib/dpkg/status

Revision history for this message
Nathan Williams (nathanw-mit) wrote :

This is fixed in dash-0.5.5 (and thus in karmic and later), with the following change:
http://git.kernel.org/?p=utils/dash/dash.git;a=commit;h=065c7bfc0cb928e9f51ee9597d41d5604acff68a

(which was actually six months prior to my bug report).

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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