Bug 24885 - /bin/sh глючит
Summary: /bin/sh глючит
Status: NEW
Alias: None
Product: Sisyphus
Classification: Development
Component: sh (show other bugs)
Version: unstable
Hardware: all Linux
: P3 normal
Assignee: placeholder@altlinux.org
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-10 06:24 MSK by at@altlinux.org
Modified: 2011-02-05 01:09 MSK (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description at@altlinux.org 2011-01-10 06:24:52 MSK
$ cat ./test.sh
#!/bin/sh -efu
echo a |
while read -r a; do
        rm /no/such/file
done
echo ok a
echo b |
        rm /no/such/file
echo ok b
$ ./test.sh
rm: cannot remove `/no/such/file': No such file or directory
ok a
rm: cannot remove `/no/such/file': No such file or directory
$

В первом случае errexit не сработал, во втором - сработал.  Мне так скрипты писать неудобно.  А то вроде скрипт отработал а потом смотришь там такой швах!
Comment 1 Alexey Gladkov 2011-01-10 10:59:32 MSK
$ sh -efu ./test.sh
rm: cannot remove `/no/such/file': No such file or directory
ok a
rm: cannot remove `/no/such/file': No such file or directory

$ dash -efu ./test.sh
rm: cannot remove `/no/such/file': No such file or directory

$ mksh -efu ./test.sh
rm: cannot remove `/no/such/file': No such file or directory
Comment 2 Dmitry V. Levin 2011-02-05 01:01:08 MSK
From bash-4.0/COMPAT:

42. Bash-4.0 changes the handling of the set -e option so that the shell exits
    if a pipeline fails (and not just if the last command in the failing
    pipeline is a simple command).  This is not as Posix specifies.  There is
    work underway to update this portion of the standard; the bash-4.0
    behavior attempts to capture the consensus at the time of release.
Comment 3 Dmitry V. Levin 2011-02-05 01:09:26 MSK
Я не буду бэкпортить это изменение в поведении bash.
Когда будем собирать более новый bash, тогда произойдет и это изменение.