Re: `if $(cmd);' is a positive when there's no output from cmd
Herculano Einloft <[EMAIL PROTECTED]> 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, [EMAIL PROTECTED] 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." ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
[:)))
Configuration Information [Automatically generated, do not change]: Machine: i686 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -pipe -m32 -march=i386 -mtune=pentium4 uname output: Linux pandp.ro 2.6.9-34.106.unsupported #1 Sat Mar 18 15:44:15 CST 2006 i686 i686 i386 GNU/Linux Machine Type: i686-redhat-linux-gnu Bash Version: 3.0 Patch Level: 15 Release Status: release Description: [Detailed description of the problem, suggestion, or complaint.] Repeat-By: [Describe the sequence of events that causes the problem to occur.] Fix: [Description of how to fix the problem. If you don't know a fix for the problem, don't include this section.] ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash