Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: anonymous functions (no documentation yet)
- X-seq: zsh-workers 25249
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Peter Stephenson <pws@xxxxxxx>
- Subject: Re: PATCH: anonymous functions (no documentation yet)
- Date: Thu, 26 Jun 2008 16:32:03 +0100
- Cc: zsh-workers@xxxxxxxxxx
- In-reply-to: <200806261506.m5QF6aCd019139@xxxxxxxxxxxxxx>
- Mail-followup-to: Peter Stephenson <pws@xxxxxxx>, zsh-workers@xxxxxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <18441.1214488302@xxxxxxx> <9646.1214491732@thecus> <200806261506.m5QF6aCd019139@xxxxxxxxxxxxxx>
On Thu, Jun 26, 2008 at 04:06:36PM +0100, Peter Stephenson wrote:
> Oliver Kiddle wrote:
> > Peter wrote:
> > > Note this does not affect cases like
> > >
> > > $emptyvariable() { ... }
> >
> > Out of interest, how does it affect:
> > ""() { ... }
>
> That also turns into an empty argument list that is ignored. I would
> have to check why since my first guess was it would produce an invalid
> empty function name.
Well,
""() echo test
''
Does echo "test".
I was finding it consistent of zsh that it would allow anything
as a function name, as there's no reason it shouldn't allow
anything that can be an argument to a simple command.
'{'() { echo test; }
Also note some funny alternatives:
$ bash -c 'a=c; a=a command eval "echo \$a; a=b; echo \$a"; echo $a'
a
b
c
$ ksh -c 'a=c; a=a command eval "echo \$a; a=b; echo \$a"; echo $a'
a
b
c
$ zsh -c 'a=c; a=a command eval "echo \$a; a=b; echo \$a"; echo $a'
zsh:1: command not found: eval
c
$ ARGV0=sh zsh -c 'a=c; a=a command eval "echo \$a; a=b; echo \$a"; echo $a'
a
b
c
$ bash -c 'a=c; a=a command . /dev/stdin << \EOF
echo $a; a=b; echo $a
EOF
echo $a'
a
b
c
$ ksh -c 'a=c; a=a command . /dev/stdin << \EOF
echo $a; a=b; echo $a
EOF
echo $a'
a
b
c
$ zsh -c 'a=c; a=a command . /dev/stdin << \EOF
echo $a; a=b; echo $a
EOF
echo $a'
zsh:1: permission denied: .
c
$ ARGV0=sh zsh -c 'a=c; a=a command . /dev/stdin << \EOF
echo $a; a=b; echo $a
EOF
echo $a'
a
b
c
Cheers,
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author