[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 <hlen@ig.com.br> 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.
>>
>>Andreas.
>
> That's not true.. try:
>
> $ echo $(echo \*)
>
> or
>
> $ a=*; echo "$a"; echo $a
>
> for illustration.
The '*' has no significance in the parser.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
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."