diff options
author | jilles <jilles@FreeBSD.org> | 2010-03-14 14:24:35 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-03-14 14:24:35 +0000 |
commit | d88c6b27847cfb6d2e02b9178df93eba8f67a461 (patch) | |
tree | 60d32e3f85931ad6ed822e0fcbfb662f567e83f9 /tools | |
parent | b9152e6b95f7273c5f4ab0f40fb6270c9220d2eb (diff) | |
download | FreeBSD-src-d88c6b27847cfb6d2e02b9178df93eba8f67a461.zip FreeBSD-src-d88c6b27847cfb6d2e02b9178df93eba8f67a461.tar.gz |
sh: Do not abort on a redirection error on a compound command.
Redirection errors on subshells already did not abort the shell because
the redirection is executed in the subshell.
Other shells seem to agree that these redirection errors should not abort
the shell.
Also ensure that the redirections will be cleaned up properly in cases like
command eval '{ shift x; } 2>/dev/null'
Example:
{ echo bad; } </var/empty/x; echo good
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/bin/sh/builtins/command11.0 | 14 | ||||
-rw-r--r-- | tools/regression/bin/sh/errors/redirection-error6.0 | 12 |
2 files changed, 26 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/builtins/command11.0 b/tools/regression/bin/sh/builtins/command11.0 new file mode 100644 index 0000000..10c8647 --- /dev/null +++ b/tools/regression/bin/sh/builtins/command11.0 @@ -0,0 +1,14 @@ +# $FreeBSD$ + +failures=0 + +check() { + if ! eval "[ $* ]"; then + echo "Failed: $*" + : $((failures += 1)) + fi +} + +check '"$({ command eval \{ shift x\; \} 2\>/dev/null; } >/dev/null; echo hi)" = hi' + +exit $((failures > 0)) diff --git a/tools/regression/bin/sh/errors/redirection-error6.0 b/tools/regression/bin/sh/errors/redirection-error6.0 new file mode 100644 index 0000000..17d1109 --- /dev/null +++ b/tools/regression/bin/sh/errors/redirection-error6.0 @@ -0,0 +1,12 @@ +# $FreeBSD$ +# A redirection error on a compound command should not abort the shell. +exec 2>/dev/null +{ echo bad; } </var/empty/x +if :; then echo bad; fi </var/empty/x +for i in 1; do echo bad; done </var/empty/x +i=0 +while [ $i = 0 ]; do echo bad; i=1; done </var/empty/x +i=0 +until [ $i != 0 ]; do echo bad; i=1; done </var/empty/x +case i in *) echo bad ;; esac </var/empty/x +exit 0 |