redirections preceded by a word with builtins inconsistent

2016-05-21 Thread adonis papaderos
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib
-D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat
-Werror=format-security -Wall
uname output: Linux venus 4.4.0-22-generic #40-Ubuntu SMP Thu May 12
22:03:46 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.3
Patch Level: 42
Release Status: release

Description:
When using redirections preceded by a word on builtins
'i.e. : {varname}<&1'
the redirection persists to the current shell.
Later using {varname}<&- does not close fd.


Repeat-By:
ls -l /proc/self/fd
: {varname}<&1
ls -l /proc/self/fd
{varname}<&-
: ls -l /proc/self/fd


Re: redirections preceded by a word with builtins inconsistent

2016-05-22 Thread adonis papaderos
I had read this before sending this message. The discussion you mention
concerns leaking named redirections from function calls. This is not what I
was trying to say. I was talking about the difference in behaviour between
the creation and the destructions of the fd. There is also the difference
in behaviour between builtins and external programs that confuses me, but
in this case I just wanted to understand the creation and the destruction.
Imho, since it is by design, there should be a mention of this is the
documentation. I'm probably nitpicking, but the reasoning behind this is
not obvious to me.

Thanks,
Adonis

2016-05-22 21:06 GMT+03:00 Chet Ramey :

> On 5/21/16 5:16 PM, adonis papaderos wrote:
>
> > Bash Version: 4.3
> > Patch Level: 42
> > Release Status: release
> >
> > Description:
> > When using redirections preceded by a word on builtins
> > 'i.e. : {varname}<&1'
> > the redirection persists to the current shell.
>
> This is by design, and has been discussed previously.  One such discussion
> starts at http://lists.gnu.org/archive/html/bug-bash/2016-01/msg00156.html
> .
> Maybe it should only do it when preceded by `exec', but it never has.
>
> > Later using {varname}<&- does not close fd.
>
> You don't precede it with an `exec', so it doesn't affect the current
> shell.  So-called `null' commands with redirections are executed in
> subshells.  This is where you need the `exec'.
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, ITS, CWRUc...@case.edu
> http://cnswww.cns.cwru.edu/~chet/
>