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


Groups > gnu.bash.bug > #14052

[BUG] failure to push/restore closed file descriptor

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Martijn Dekker <martijn@inlv.org>
Newsgroups gnu.bash.bug
Subject [BUG] failure to push/restore closed file descriptor
Date Mon, 23 Apr 2018 19:54:11 +0200
Lines 26
Approved bug-bash@gnu.org
Message-ID <mailman.12897.1524506067.27995.bug-bash@gnu.org> (permalink)
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1524506067 4156 208.118.235.17 (23 Apr 2018 17:54:27 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.7.0
Content-Language en-GB
X-detected-operating-system by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From 37.59.109.123
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14052

Show key headers only | View raw


$ 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

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web