| Summary: | /bin/sh глючит | ||
|---|---|---|---|
| Product: | Sisyphus | Reporter: | at <at> |
| Component: | sh | Assignee: | placeholder <placeholder> |
| Status: | NEW --- | QA Contact: | qa-sisyphus |
| Severity: | normal | ||
| Priority: | P3 | CC: | glebfm, ldv, placeholder, vt, vvk |
| Version: | unstable | ||
| Hardware: | all | ||
| OS: | Linux | ||
$ 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 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.
Я не буду бэкпортить это изменение в поведении bash. Когда будем собирать более новый bash, тогда произойдет и это изменение. |
$ 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 не сработал, во втором - сработал. Мне так скрипты писать неудобно. А то вроде скрипт отработал а потом смотришь там такой швах!