Re: Use of pipe in $( filename | program) returns null

2009-11-28 Thread Bernd Eggink

Am 28.11.2009 06:35, schrieb r...@saturn.syslang.net:


Description:
use of $(  filename | program) does not work. It either should or it 
should be properly documented.
The problem also happens on bash4.

Repeat-By:

qq=$(  /etc/passwd | grep sys)
echo $qq
# result is null

Fix:
Either fix the docs to tell people that a pipe is not allowed or fix 
the code to allow it.


The problem is not the pipe but the fact that 'filename' is an empty 
command which does nothing. If you want 'program' to read from 'file', 
use 'programfile'.


Bernd

--
Bernd Eggink
http://sudrala.de




Re: Use of pipe in $( filename | program) returns null

2009-11-28 Thread Andreas Schwab
Bernd Eggink mono...@sudrala.de writes:

 Am 28.11.2009 06:35, schrieb r...@saturn.syslang.net:

 Description:
  use of $(  filename | program) does not work. It either should or it 
 should be properly documented.
  The problem also happens on bash4.

 Repeat-By:

  qq=$(  /etc/passwd | grep sys)
  echo $qq
  # result is null

 Fix:
  Either fix the docs to tell people that a pipe is not allowed or fix 
 the code to allow it.

 The problem is not the pipe but the fact that 'filename' is an empty
 command which does nothing. If you want 'program' to read from 'file', use
 programfile'.

Or even $( /etc/passwd grep sys).

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.




Re: Use of pipe in $( filename | program) returns null

2009-11-28 Thread DennisW
On Nov 28, 4:46 am, Andreas Schwab sch...@linux-m68k.org wrote:
 Bernd Eggink mono...@sudrala.de writes:
  Am 28.11.2009 06:35, schrieb r...@saturn.syslang.net:

  Description:
         use of $(  filename | program) does not work. It either should or 
  it should be properly documented.
         The problem also happens on bash4.

  Repeat-By:

         qq=$(  /etc/passwd | grep sys)
         echo $qq
         # result is null

  Fix:
         Either fix the docs to tell people that a pipe is not allowed or 
  fix the code to allow it.

  The problem is not the pipe but the fact that 'filename' is an empty
  command which does nothing. If you want 'program' to read from 'file', use
  programfile'.

 Or even $( /etc/passwd grep sys).

 Andreas.

 --
 Andreas Schwab, sch...@linux-m68k.org
 GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
 And now for something completely different.

Or even $(grep sys /etc/passwd)


Re: Use of pipe in $( filename | program) returns null

2009-11-28 Thread Chet Ramey
r...@saturn.syslang.net wrote:

 Description:
   use of $( filename | program) does not work. It either should or it 
 should be properly documented.
   The problem also happens on bash4.
 
 Repeat-By:
 
   qq=$( /etc/passwd | grep sys)
   echo $qq
   # result is null
 
 Fix:
   Either fix the docs to tell people that a pipe is not allowed or fix 
 the code to allow it.

That construct is very limited.  As the bash man page says:

The command substitution $(cat file) can be replaced by the equivalent
but faster $( file).

That seems pretty clear.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/




Re: Use of pipe in $( filename | program) returns null

2009-11-28 Thread pk
Chet Ramey wrote:

 r...@saturn.syslang.net wrote:
 
 Description:
 use of $( filename | program) does not work. It either should or it
 should be properly documented. The problem also happens on bash4.
 
 Repeat-By:
 
 qq=$( /etc/passwd | grep sys)
 echo $qq
 # result is null
 
 Fix:
 Either fix the docs to tell people that a pipe is not allowed or fix the
 code to allow it.
 
 That construct is very limited.  As the bash man page says:
 
 The command substitution $(cat file) can be replaced by the equivalent
 but faster $( file).
 
 That seems pretty clear.

Yeah, and then based on that he probably thought that

$(cat file | grep sys)

could be replaced by

$( file | grep sys)

which is not the case.


Use of pipe in $( filename | program) returns null

2009-11-27 Thread root
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' 
-DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib  -D_GNU_SOURCE 
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall 
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic 
-fasynchronous-unwind-tables
uname output: Linux saturn.syslang.net 2.6.27.30-170.2.82.fc10.i686.PAE #1 SMP 
Mon Aug 17 08:24:23 EDT 2009 i686 athlon i386 GNU/Linux
Machine Type: i386-redhat-linux-gnu

Bash Version: 3.2
Patch Level: 39
Release Status: release

Description:
use of $( filename | program) does not work. It either should or it 
should be properly documented.
The problem also happens on bash4.

Repeat-By:

qq=$( /etc/passwd | grep sys)
echo $qq
# result is null

Fix:
Either fix the docs to tell people that a pipe is not allowed or fix 
the code to allow it.