[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FDs greater than 9 can't be closed
From: |
greg |
Subject: |
FDs greater than 9 can't be closed |
Date: |
11 Apr 2007 19:32:57 -0000 |
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: openbsd3.9
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='openbsd3.9' -DCONF_MACHTYPE='i386-unknown-openbsd3.9'
-DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -I/usr/local/include
-O2 -pipe
uname output: OpenBSD pegasus 4.0 GENERIC#1 i386
Machine Type: i386-unknown-openbsd3.9
Bash Version: 3.1
Patch Level: 1
Release Status: release
Description:
File descriptors greater than 9 seem to ignore move/close
redirections (e.g. 17<&-). This problem does not occur in
earlier versions of bash, so it appears to be a regression.
Repeat-By:
Given this script:
#!/usr/local/bin/bash
exec 17<bar
read <&17; echo "$REPLY"
exec 17<&- 17<bar
read <&17; echo "$REPLY"
And this data file:
line 1
line 2
Running the script under bash 3.1 gives this output:
line 1
line 2
But under bash 3.0 or bash 2.05b (tested on two other platforms)
it gives this output:
line 1
line 1
Likewise, this script:
#!/usr/local/bin/bash
exec 17<bar
read <&17 && echo "$REPLY"
exec 17<&-
read <&17 && echo "$REPLY"
Using the same data file, gives the following output under 3.1:
line 1
line 2
And this output under 2.05b or 3.0:
line 1
foo: line 5: 17: Bad file descriptor
I get similar results with file descriptor 10, but I don't see
the problem with file descriptor 9. It looks like there might
be a parsing change that causes a problem with multiple-digit FDs
and the <& or >& operators.
This problem was originally noted by "svizzero" in Freenode's
#bash channel. I'm just reporting it so it can be fixed.
Fix:
The only workaround I've found is "don't use FDs greater than 9".
- FDs greater than 9 can't be closed,
greg <=