Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14052 > unrolled thread

[BUG] failure to push/restore closed file descriptor

Started byMartijn Dekker <martijn@inlv.org>
First post2018-04-23 19:54 +0200
Last post2018-04-23 19:54 +0200
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug


Contents

  [BUG] failure to push/restore closed file descriptor Martijn Dekker <martijn@inlv.org> - 2018-04-23 19:54 +0200

#14052 — [BUG] failure to push/restore closed file descriptor

FromMartijn Dekker <martijn@inlv.org>
Date2018-04-23 19:54 +0200
Subject[BUG] failure to push/restore closed file descriptor
Message-ID<mailman.12897.1524506067.27995.bug-bash@gnu.org>
$ bash -c '{ exec 8</dev/null; } 8<&-; : <&8 && echo "oops, still open"'
Output: "oops, still open"
Expected output: Bad file descriptor

Apparently, bash either fails to push the file descriptor onto the stack 
at '} 8<&-', or fails to restore it.

Same bug with loops ending in "done 8<&-".

Confirmed in all bash versions down to 2.05b.

Also note that pushing an open file descriptor works as expected:

$ bash -c '{ exec 8</dev/null; } 8</dev/tty; : <&8 && echo "oops, still 
open"'
Output: Bad file descriptor (as expected)

FYI:
* bash and dash have this bug;
* zsh, yash, AT&T ksh93, pdksh, mksh, posh, schily's bosh, Busybox ash, 
FreeBSD sh, and NetBSD sh all do this correctly.

Thanks,

- Martijn

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web