helpThe GNU Bourne-Again SHell - Support: sr #109690, script exits prematurely if...


sr #109690: script exits prematurely if function call contains ssh, when input is from heredoc

Submitted by:  None
Submitted on:  Fri 31 May 2019 10:06:39 PM UTC  
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Invalid
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  GNU/Linux

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Fri 07 Jun 2019 02:37:12 PM UTC, comment #1: 

Processes inherit file descriptors from their parent, so the standard input for the shell becomes the standard input for ssh. That standard input is the here document. ssh consumes its standard input unless supplied the -n option. There is a single file offset pointer shared among all processes that share the same file descriptor. Once the ssh child process reads its standard input and consumes the data in the here document, it's not available for the parent shell to read.

Chet Ramey <chet>
Project Administrator
Fri 31 May 2019 10:06:39 PM UTC, original submission:  

Use any host where you can ssh without password prompt
Here I am using localhost, but you can use different box

Type in on bash prompt:

bash << +++
function test_ssh() {
ssh localhost hostname
echo after test_ssh - this printout will be missing


As you can see, output from echo command is missing. Script exit prematurely.
Bug shows only when input is from heredoc (+++)



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-06-07 chet StatusNone => Invalid

    Back to the top

    Powered by Savane 3.5