[Bug 141481] Re: dash as #!/bin/sh introduces countless incompatibilities
Victor Mitin
141481 at bugs.launchpad.net
Sun Dec 25 12:08:22 UTC 2011
There is one more DASH bug.
Described here:
http://groups.google.com/group/vim_use/browse_thread/thread/837988813a06c280/f8b4aadd575affaa?lnk=gst&q=expect#f8b4aadd575affaa
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to dash in Ubuntu.
https://bugs.launchpad.net/bugs/141481
Title:
dash as #!/bin/sh introduces countless incompatibilities
Status in “dash” package in Ubuntu:
Invalid
Bug description:
Binary package hint: dash
Hi,
I understand the rationale of using a lightweight bourne shell clone for #!/bin/sh instead of bash, however Ubuntu's use of dash as #!/bin/sh by default has broken countless scripts and brought us back into the dark ages of platform-specific scripting. Bashisms and various unixy #!/bin/sh variant quirks are well understood in their incomatabilites (especially by the autoconf/autopackage people), except this new player - dash.
Software vendors, open source projects and even the ubuntu BTS are flooded with bugs that stem from dash incompatabilites, which are often hard to debug the root cause of. Examples:
https://bugs.launchpad.net/ubuntu/+source/dash/+bug/92189
https://bugs.launchpad.net/ubuntu/+source/dash/+bug/105634
https://bugs.launchpad.net/ubuntu/+source/dash/+bug/71887
https://bugs.launchpad.net/ubuntu/+source/dash/+bug/135863
https://bugs.launchpad.net/ubuntu/+source/dash/+bug/128730
This is not a duplicate bug report - it the a compound of all the above bugs that
Examples of 3rd party apps that break:
the ATI installer, vmWare, Xen, Mathematica, NX Server, MKS, NVC and anything else that relies on a sane #!/bin/sh
The scope of this problem is rather large. It would be reasonable to
say "fix the scripts" if the scripts were buggy, but alas this is not
the case.
The following code snippets are extracted from live, working scripts
that are used frequently, that work in other versions of #!/bin/sh,
but break in dash:
$ dash -c 'cnt=6; while [ $((cnt = cnt - 1)) -gt 0 ]; do echo $cnt; done'
dash: arith: syntax error: "cnt = cnt - 1"
$ dash-c 'if false; then d="${foo/bar}"; fi'
dash: Syntax error: Bad substitution
$ dash -c 'a=water;echo ${a:2:2}'
dash: Syntax error: Bad substitution
$ dash -c 'exec 20<&0'
exec: 1: 20: not found
$ dash -c 'echo $UID'
# no output. how on earth are we supposed to safely and portably get the UID?
$ dash -c 'echo hello 2>&1>/dev/null'
dash: Syntax error: redirection unexpected
$ dash -c 'x="1 2"; local y=$x; echo $y'
local: 1: 2: bad variable name
And an example from makeself:
shh.sh:
#!/bin/sh
tmpfile=foo
tmpdir=/tmp/dashtmp
mkdir "$tmpdir"
( cd "$tmpdir" && ( tar cvf - . | eval "gzip -c9" ) >> "$tmpfile" ) || { echo "Failed"; exit 1; }
echo >> "$tmpfile" >&-
$ ./shh.sh
./
./foo
./shh: line 6: echo: write error: Bad file descriptor
I invite others to collect similar examples here. If Ubuntu will not
fix dashisms then we must support dash, which is why a compilation of
incompatabilities is necessary, so that a list of workarounds can be
put together, à la
http://www.gnu.org/software/autoconf/manual/html_node/Portable-
Shell.html, http://code.dogmap.org/lintsh/ and http://steve-
parker.org/sh/sh.shtml which mostly cover outdated incompatabilites
between other shells.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/dash/+bug/141481/+subscriptions
More information about the foundations-bugs
mailing list