bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[BUG] failure to push/restore closed file descriptor


From: Martijn Dekker
Subject: [BUG] failure to push/restore closed file descriptor
Date: Mon, 23 Apr 2018 19:54:11 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

$ 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]