Subject: Re: correct shell behaviour?
From: David Laight <email@example.com>
Date: 08/12/2002 10:31:27
> A quick test shows that ksh93's "0" is the status of the "echo a".
> $ echo `cmp -s /etc/group /etc/group; exit 3` >`echo /dev/tty; exit 2` $?
> $ echo `cmp -s /etc/passwd /etc/group; exit 3` >`echo /dev/tty; exit 2` $?
> $ echo `if cmp -s /etc/passwd /etc/grope; then exit 3; else exit 4; fi` $?
> These results are... counterintuitive.
Erm badly broken? It looks as though 'exit n' isn't setting the result!
> > x=$(echo var >&2) : >/dev/null$(echo redir >&2) $(echo arg >&2)
> All but V7 sh agree:
The posix spec says arg, redir, var for normal commands but allows
arg, var, redir for 'special builtins' (which include : but not echo).
> Apparently not... but for
> $ (exit 2)
> $ a=a
> $ echo $?
> all do produce
That is the behaviour that posix requests.
David Laight: firstname.lastname@example.org