🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #880

$() fails if stdin and stdout are not open

#880
From: 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.
Technical Details
Message-ID: <mcook.713640511@fendahl.dev.cdx.mot.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!merlin.DEv.cdx.mot.COM!mcook

Show Full Headers
Complete Article Headers
Newsgroups: gnu.bash.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!merlin.DEv.cdx.mot.COM!mcook
From: mcook@merlin.DEv.cdx.mot.COM (Michael Cook)
Subject: $() fails if stdin and stdout are not open
Message-ID: <mcook.713640511@fendahl.dev.cdx.mot.com>
Sender: gnulists@ai.mit.edu
Organization: Motorola Codex, Canton, Massachusetts
Distribution: gnu
Date: Wed, 12 Aug 1992 17:28:31 GMT
Approved: bug-bash@prep.ai.mit.edu
Lines: 34