bug-bash
[Top][All Lists]
Advanced

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

Script ends prematurely when fed into bash's stdin


From: nick
Subject: Script ends prematurely when fed into bash's stdin
Date: Mon, 19 Sep 2005 19:22:49 -0400 (EDT)

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: i686-pc-linux-gnu-gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib   -O2 -march=i686 
-fomit-frame-pointer
uname output: Linux alphaville.zko.hp.com 2.6.12-gentoo-r6 #4 Thu Sep 1 
11:04:19 EDT 2005 i686 Intel(R) Pentium(R) M processor 1600MHz GenuineIntel 
GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 3.0
Patch Level: 16
Release Status: release

Description:
        Consider a script that invokes ssh to execute a remote command
        (I've set up public key authentication, so no passwords are needed):

                 ssh remote date
                 date
                 ssh remote date
                 date
                 exit 0

        If I invoke bash and give it the script filename as argument,
        it works fine. But if I pipe the script file into bash or
        redirect bash's stdin so that it comes from the script file,
        bash quits immediately after the (first) ssh command is finished.
        stracing the bash invocation shows that bash gets an EOF on
        the read after the ssh command is done. Although ssh is
        essential to this behavior, I cannot see how ssh could fiddle
        with bash's stdin, so I decided to submit is as a bash bug -
        but I may be wrong.

        My current workaround is to redirect ssh's stdin from /dev/null:

                 ssh remote date </dev/null
                 date
                 ssh remote date </dev/null
                 date
                 exit 0


Repeat-By:
        Create a file, say junk.sh,  with the commands above.
        I believe that the following three invocations should
        give me identical output (that of the third invocation).
        This is what I get:
        
           $ cat junk.sh | bash
           Mon Sep 19 19:07:40 EDT 2005
           $ bash < junk.sh
           Mon Sep 19 19:07:48 EDT 2005
           $ bash junk.sh
           Mon Sep 19 19:07:52 EDT 2005
           Mon Sep 19 19:07:52 EDT 2005
           Mon Sep 19 19:07:53 EDT 2005
           Mon Sep 19 19:07:53 EDT 2005
           $ 
        





reply via email to

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