Skip to main content
do not 'QUOTE' close of heredoc
Source Link
thrig
  • 35.8k
  • 4
  • 70
  • 88

You're doing:

bash << 'EOT'
some-command-that-reads-stdin
EOT

But some-command-that-reads-stdin's stdin will be that here document as well, as it is started by bash so inherits the same stdin.

You could do:

bash /dev/fd/3 3<< 'EOT'
some-command-that-reads-stdin
EOT

So stdin is left untouched, and bash gets the code from that here document on another fd.

Note: I can't save this edit because I just remove single quote marks from last EOF and it's not enough for saving: Reviewer, Please remove them yourself.

You're doing:

bash << 'EOT'
some-command-that-reads-stdin
EOT

But some-command-that-reads-stdin's stdin will be that here document as well, as it is started by bash so inherits the same stdin.

You could do:

bash /dev/fd/3 3<< 'EOT'
some-command-that-reads-stdin
EOT

So stdin is left untouched, and bash gets the code from that here document on another fd.

Note: I can't save this edit because I just remove single quote marks from last EOF and it's not enough for saving: Reviewer, Please remove them yourself.

You're doing:

bash << 'EOT'
some-command-that-reads-stdin
EOT

But some-command-that-reads-stdin's stdin will be that here document as well, as it is started by bash so inherits the same stdin.

You could do:

bash /dev/fd/3 3<< 'EOT'
some-command-that-reads-stdin
EOT

So stdin is left untouched, and bash gets the code from that here document on another fd.

Worked fine without single quoute marks for last EOT... With them it just didn't work...
Source Link

You're doing:

bash << 'EOT'
some-command-that-reads-stdin
'EOT'EOT

But some-command-that-reads-stdin's stdin will be that here document as well, as it is started by bash so inherits the same stdin.

You could do:

bash /dev/fd/3 3<< 'EOT'
some-command-that-reads-stdin
'EOT'EOT

So stdin is left untouched, and bash gets the code from that here document on another fd.

Note: I can't save this edit because I just remove single quote marks from last EOF and it's not enough for saving: Reviewer, Please remove them yourself.

You're doing:

bash << 'EOT'
some-command-that-reads-stdin
'EOT'

But some-command-that-reads-stdin's stdin will be that here document as well, as it is started by bash so inherits the same stdin.

You could do:

bash /dev/fd/3 3<< 'EOT'
some-command-that-reads-stdin
'EOT'

So stdin is left untouched, and bash gets the code from that here document on another fd.

You're doing:

bash << 'EOT'
some-command-that-reads-stdin
EOT

But some-command-that-reads-stdin's stdin will be that here document as well, as it is started by bash so inherits the same stdin.

You could do:

bash /dev/fd/3 3<< 'EOT'
some-command-that-reads-stdin
EOT

So stdin is left untouched, and bash gets the code from that here document on another fd.

Note: I can't save this edit because I just remove single quote marks from last EOF and it's not enough for saving: Reviewer, Please remove them yourself.

Source Link
Stéphane Chazelas
  • 585.2k
  • 96
  • 1.1k
  • 1.7k

You're doing:

bash << 'EOT'
some-command-that-reads-stdin
'EOT'

But some-command-that-reads-stdin's stdin will be that here document as well, as it is started by bash so inherits the same stdin.

You could do:

bash /dev/fd/3 3<< 'EOT'
some-command-that-reads-stdin
'EOT'

So stdin is left untouched, and bash gets the code from that here document on another fd.