🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Michael Cook Wed, 12 Aug 1992 17:28
$() fails if stdin and stdout are not open
#880
Author: Michael Cook
Date: Wed, 12 Aug 1992 17:28
33 lines
1462 bytes
If bash is run with stdin and stdout closed, the backquoting mechanism fails.
Look:

bash$ bash -c 'echo foo$(echo bar)baz >/dev/tty' >&- <&-
foobaz

If either stdin or stdout is open, it works okay:

bash$ bash -c 'echo foo$(echo bar)baz >/dev/tty'
foobarbaz
bash$ bash -c 'echo foo$(echo bar)baz >/dev/tty'          <&-
foobarbaz
bash$ bash -c 'echo foo$(echo bar)baz >/dev/tty'      >&-
foobarbaz
bash$ bash -c 'echo foo$(echo bar)baz >/dev/tty'      >&- <&-
foobaz
bash$ bash -c 'echo foo$(echo bar)baz >/dev/tty' 2>&-
foobarbaz
bash$ bash -c 'echo foo$(echo bar)baz >/dev/tty' 2>&-     <&-
foobarbaz
bash$ bash -c 'echo foo$(echo bar)baz >/dev/tty' 2>&- >&-
foobarbaz
bash$ bash -c 'echo foo$(echo bar)baz >/dev/tty' 2>&- >&- <&-
foobaz
bash$

(On our system (ULTRIX 4.2), when an X session is started, the $SHELL that is
run to startup the window manager has stdin and stdout closed.  Lord only
knows why...)

Bash should be made smart enough to handle this, shouldn't it?

Michael.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads