[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: `if $(cmd);' is a positive when there's no output from cmd

From: Andreas Schwab
Subject: Re: `if $(cmd);' is a positive when there's no output from cmd
Date: Sun, 16 Apr 2006 14:46:35 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux)

Herculano Einloft <address@hidden> writes:

> Em (02:25:11), Andreas Schwab escreveu: 
>>> Hey all, 
>>> $ if $(echo string >/dev/null); then echo true; fi 
>>> true 
>>> This should be a syntax error 
>>No, it is a perfectly valid command, syntactically. That the command 
>>substitution expands to nothing has no significance any more once the 
>>command is parsed, just like shell meta characters resulting from 
>>expansions are taken literally. 
> That's not true.. try: 
> $ echo $(echo \*) 
> or 
> $ a=*; echo "$a"; echo $a 
> for illustration. 

The '*' has no significance in the parser.


Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]