bug-bash
[Top][All Lists]
Advanced

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

printf "1\n2\n3\n" | head -2 | (exec 3<&0; cat /dev/fd/3)


From: Edward J. Huff
Subject: printf "1\n2\n3\n" | head -2 | (exec 3<&0; cat /dev/fd/3)
Date: Sun, 7 Nov 2004 23:08:18 -0500

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: i386-redhat-linux-gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' 
-DCONF_VENDOR='redhat' -DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib 
-D_FILE_OFFSET_BITS=64 -O2 -g -pipe -march=i386 -mcpu=i686
uname output: Linux ducks.huff20may77.us 2.6.8-1.521 #1 Mon Aug 16 09:01:18 EDT 
2004 i686 i686 i386 GNU/Linux
Machine Type: i386-redhat-linux-gnu

Bash Version: 2.05b
Patch Level: 0
Release Status: release

Description:
        The commands described below behave inconsistently, so far as
        I can see.  (exec 3<&0; cat /dev/fd/3) should always find
        an existing file at /dev/fd/3.  Sometimes it doesn't.

Repeat-By:
---
        $ printf "1\n2\n3\n" | (exec 3<&0; cat /dev/fd/3)
        1
        2
        3
---
        $ printf "1\n2\n3\n" | head -2 | (exec 3<&0; cat /dev/fd/3)
        cat: /dev/fd/3: No such file or directory
---
        $ bash -c 'printf "1\n2\n3\n" | head -2 | (exec 3<&0; cat /dev/fd/3)'
        1
        2
---
        $ (printf "1\n2\n3\n" | head -2) | (exec 3<&0; cat /dev/fd/3)
        1
        2
---
        $ /usr/bin/printf "1\n2\n3\n" | /bin/cat | ( (exec 3<&0; /bin/cat 
/dev/fd/3) )
        /bin/cat: /dev/fd/3: No such file or directory
---
        $ /usr/bin/printf "1\n2\n3\n" | /bin/cat | ( /bin/cat | (exec 3<&0; 
/bin/cat /dev/fd/3) )
        1
        2
        3




reply via email to

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