Stephane Chazelas <stephane.chaze...@gmail.com> wrote:

> One more major issue identified in this thread is that in TC2,
> the "until" in
>
> < file until...
>
> or:
>
> foo=bar until...
>
> is now required to be recognised as the "until" keyword, and
> it's not in most shells (an exception is zsh for the first
> case).

Could you explain since when this is required?

>From what I can tell, a macro assignement before one of the complex commands 
"if", "case", "while", ... never works.

It is however a bug that the Bourne Shell and it's derivates like ksh and bosh
do not allow a I/O redirection before such a command since it is permitted
after a command already.


> < file time cmd
> < file ! cmd
> a=1 ! cmd # that one unclear whether the a=1 would apply to all
>           # the commands in the pipeline though
> < file { ...; }
>
> as an extension.

< file time cmd         already works in Bourne Shell and it's children
< file ! cmd            The fact that this does not work must be seen
                        as a bug since both constructs are parsed the same way.

> BTW, several shells (ksh93, mksh, zsh) support: < file (subshell)
> I've not checked whether that was allowed/required/prohibited by
> the POSIX grammar.
>
> See also:
>
> $ ksh -c '< file f() { echo x; }; typeset -f'
> f() { echo x; }; # missing newline

This seems to be a funny bug as it looks like ';' is written instead of a 
newline ;-)

> $ zsh -c '< file f() { echo x; }; typeset -f'
> f () {
>         echo x
> } < file

This looks like a bug: the command that is redirected is the function 
definition, so "< file" does not belong here.


BTW: 

bosh -c '< file f() { echo x; }; type -F'
f(){
echo x
}

Note that "typeset" is not part of POSIX, bosh therefore uses "type -F" as 
discussed on the POSIX teleconferences and bug reports.

mksh -c '< file f() { echo x; }; typeset -f' 
mksh: syntax error: '(' unexpected

Nice Bug.

> $ ksh -c 'f() < file (echo x); typeset -f'
> ksh: syntax error at line 1: `<' unexpected

This is illegal syntax, a corrected variant of what you seem to intend is e.g.:

bosh -c 'f() { < file (echo x); }; type -F'
f(){
(echo x) 0<file
}

BTW: ksh works here as well.

Note that the syntax-tree -> text converter in bosh is highly tested as it is 
used while parsing $(cmd) constructs and $(cmd) would not work if the result
from the syntax-tree -> text converter did create text that is not accepted by 
the parser to create the same syntax tree again.

> $ mksh -c 'f() < file (echo x); typeset -f'
> f() ( echo x ) <file
> $ zsh -c 'f() < file (echo x); typeset -f'
> f () {
>         (
>                 echo x
>         ) < file
> }

As mentioned: if this works, the related shell has a parser bug.

Jörg

-- 
 EMail:jo...@schily.net                    (home) Jörg Schilling D-13353 Berlin
    joerg.schill...@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/
 URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/'

Reply via email to