Package: dash
Version: 0.5.5.1-7.4
Severity: normal

Steps to reproduce:

    $ cat /tmp/test.sh
    false
    . /dev/null
    echo $?
    $ dash /tmp/test.sh
    1
    $ bash /tmp/test.sh
    0

The only reference I can find to POSIX behaviour of "." says[1]:

    EXIT STATUS: Returns the value of the last command executed, or a zero
    exit status if no command is executed.

In the above example, no command is executed (since /dev/null is empty) but the
resulting exit status is not zero; in fact, it's left-over from the invocation
of "false". For the record, "busybox sh" behaves the same way as dash, as does
posh.

I came across this problem in a script that used "set -e". Here's
a slightly less minimal test-case:

    $ cat /tmp/test2.sh 
    set -e
    if false; then
        echo "hello"
    else
        . /dev/null
    fi
    $ dash /tmp/test2.sh; echo $?
    1

The "." builtin is treated as having failed, even though it was the condition
of the if statement that set $? to a non-zero value.

[1] http://pubs.opengroup.org/onlinepubs/009695399/utilities/dot.html

-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.30-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages dash depends on:
ii  debianutils                   3.4.4      Miscellaneous utilities specific t
ii  dpkg                          1.15.8.10  Debian package management system
ii  libc6                         2.11.2-11  Embedded GNU C Library: Shared lib

dash recommends no packages.

dash suggests no packages.

-- debconf information:
* dash/sh: true



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to