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

Re: sh compatibility issue



> !(...) without space

I think the POSIX spec requires this to work, but that may not be
intentional. '(' is an operator and therefore it does not need a space
between it and other characters (except to disambiguate between two
adjacent operators and one two-character operator). It may not be
intentional because it conflicts with ksh extended pattern matching.

More generally, this rule also means that things like
  while(true)do(pwd)done
do not need any spaces. Although this example is contrived, I can
imagine there are real scripts that zsh fails to parse because of this;
the other shells I tried execute it correctly.

The situation for '!{' is different. '{' is a reserved word and
therefore it is not recognized. Instead, this describes a utility (or
alias) that probably does not exist. I do not recommend making special
allowances for it.

On a related note, here is another quite insidious sh compatibility
issue:
  sh -c 'exec </nonexistent/a; echo wrong'
This should not print "wrong" because exec is a special builtin and
redirection errors on special builtins are fatal. Most shells get this
right nowadays (bash only in POSIX mode) but zsh gets it wrong. Even
  set -o posixbuiltins
does not help.

-- 
Jilles Tjoelker



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