|[2 earlier articles]|
|Re: magic/absurd bash interpreter/compiler ? firstname.lastname@example.org (Jonathan Thornburg) (2012-12-24)|
|Re: magic/absurd bash interpreter/compiler ? email@example.com (Eric) (2012-12-24)|
|Re: magic/absurd bash interpreter/compiler ? firstname.lastname@example.org (Barry Margolin) (2012-12-24)|
|Re: magic/absurd bash interpreter/compiler ? email@example.com (glen herrmannsfeldt) (2012-12-25)|
|Re: magic/absurd bash interpreter/compiler ? firstname.lastname@example.org (Eric) (2012-12-26)|
|Re: magic/absurd bash interpreter/compiler ? email@example.com (glen herrmannsfeldt) (2012-12-28)|
|Re: magic/absurd bash interpreter/compiler ? firstname.lastname@example.org (Barry Margolin) (2012-12-28)|
|From:||Barry Margolin <email@example.com>|
|Date:||Fri, 28 Dec 2012 10:25:33 -0500|
|Organization:||A noiseless patient Spider|
|References:||12-12-014 12-12-018 12-12-020 12-12-021 12-12-025|
|Keywords:||design, history, comment|
|Posted-Date:||29 Dec 2012 16:49:19 EST|
glen herrmannsfeldt <firstname.lastname@example.org> wrote:
> In comp.compilers Eric <email@example.com> wrote:
> (snip, I wrote)
> >> One problem with many unix shells is that redirection is done too early.
> >> Specifically, before an if test is done.
> > I am tempted to think that this is a conceptual misunderstanding, so an
> > example would be useful.
> From the man page for csh:
> "The single-command form of if does output redirection even if the
> expression is false and the command is not executed."
> echo false > file
> if( 1 > 2 ) echo true > file
> The if statement will open (and truncate) file before
> testing the condition. At least for csh, I didn't try others.
> -- glen
> [That's one of the many, many bugs in csh. In posix shells such as
> sh and bash, they do what you'd expect:
> if [ 1 \> 2 ]; then echo true > file; fi # doesn't create the file
> if [ 1 \> 2 ]; then echo true; fi > file # does create it
csh is so broken, it's best ignored when talking about "Unix shells" in
general. Even more so when someone says "many Unix shells", since one
exception hardly counts as "many".
Barry Margolin, firstname.lastname@example.org
[Several other people wrote to agree that csh is bad news. -John]
Return to the
Search the comp.compilers archives again.