bug-bash
[Top][All Lists]
Advanced

[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 02:25:11 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux)

Herculano Einloft <hlen@ig.com.br> writes:

> 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.

-- 
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."




reply via email to

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