Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: cshjunkieparen bothers me (and always has)
- X-seq: zsh-workers 1527
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: Zoltan Hidvegi <hzoli@xxxxxxxxxx>
- Subject: Re: cshjunkieparen bothers me (and always has)
- Date: Thu, 4 Jul 1996 08:58:51 -0700
- Cc: pws@xxxxxx, zsh-workers@xxxxxxxxxxxxxxx
- In-reply-to: Zoltan Hidvegi <hzoli@xxxxxxxxxx> "Re: cshjunkieparen bothers me (and always has)" (Jul 4, 3:14pm)
- References: <199607041314.PAA11866@xxxxxxxxxxxxxxxxx>
- Reply-to: schaefer@xxxxxxx
On Jul 4, 3:14pm, Zoltan Hidvegi wrote:
> Subject: Re: cshjunkieparen bothers me (and always has)
>
> > I *think* this is what happened:
> >
> > Cshjunkieparen at one time affected whether
> >
> > if [[ $TERM == xterm ]] then
> >
> > would work. This was the csh compatibility feature, even though it
> > wasn't precisely csh syntax. I have no idea why "paren" was used in
> > the name of the option.
>
> This syntax is really a ksh compatibility syntax. But by a more general
> rure it is a POSIX compatibility syntax.
That may be, but there wasn't any such thing as `POSIX compatibility' (at
least within zsh) at the time that it was originally introduced as csh
compatibility.
> The biggest problem using braces instead of then ... fi is the following:
>
> if (true)
> { echo yes; }
>
> The patch I posted recently to the manual says that it is equivalent to
>
> if (true)
> then
> echo yes
> fi
>
> But that's not true since par_list parses a list as long as it is possible
> so the above is the same as
>
> if (true) ; { echo yes; }
>
> And now a then or an open brace should come after some semicolons. I think
> csh junkies do not like that change.
I don't think csh junkies care one way or the other. C junkies might,
but braces are not a command-grouping syntax in csh EXCEPT in exactly
one circumstance:
#! /bin/csh
if { something } then
echo something succeeded
endif
I.e., in "if" (and possibly "while", I forget) statements, using braces
instead of parens is equivalent to:
#! /bin/csh
something
if ( $status == 0 ) then
echo something succeeded
endif
> if true {
> echo yes
> }
>
> does not work either since { behaves like a reserved word (POSIX says that
> { and } should be reserved words).
That's equivalent to passing '{' as an argument to 'true', which is fine.
No problem with that either from a csh junkie standpoint; you can't omit
the parens in csh. I note that this works:
if { true } {
echo yes
}
> To summarize this after Bart's patch the
>
> if (foo)
> {
> ...
> }
>
> syntax will not work
But that in turn means that
if [[ -f foo ]]
{
...
}
has never worked, or at least hasn't worked for quite some time. (Boy,
sometimes I wish my old machine with the 2.0.0 zsh on it hadn't died.)
In any case, I think this bit of consistency is worthwhile.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.nbn.com/people/lantern
New male in /home/schaefer:
>N 2 Justin William Schaefer Sat May 11 03:43 53/4040 "Happy Birthday"
Messages sorted by:
Reverse Date,
Date,
Thread,
Author