Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: sh compatibility issue



I notice that the patches were committed. This indeed fixes some things
(FreeBSD sh testsuite errors/redirection-error.0 which checks that
redirection errors for special builtins are fatal) but breaks another
test which happened to pass before: errors/redirection-error3.0 which
checks that redirection errors are not fatal for special builtins
preceded by the command builtin.

Although 'command' is often implemented as some sort of precommand
modifier, the POSIX specification says it is a regular builtin,
therefore redirection errors are not fatal (and variable assignments do
not persist). The specification also says that 'command' causes operand
(syntax) errors to be non-fatal.

A useful example is in the Application Usage section of the 'command'
page:
  command exec > unwritable-file
This does not cause the shell to abort, so the exit status can be
checked by the script.

This works as specified in ksh93, bash --posix and FreeBSD 9 sh, for
example.

-- 
Jilles Tjoelker



Messages sorted by: Reverse Date, Date, Thread, Author