bug-bash
[Top][All Lists]
Advanced

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

Re: eval doesn't close file descriptor?


From: Matei David
Subject: Re: eval doesn't close file descriptor?
Date: Tue, 12 Feb 2013 12:34:40 -0500

Wow, thanks, I didn't know that. So this syntax achieves a bit more than I
asked for- it allows you to get a new unused file descriptor, right? It
seems that the only useful way to use a non-closing form (>&-, <&-) is with
exec, as in 'exec {new_fd}>&2'. (Why would I want the fd in a variable
otherwise.)

Too bad the "natural" syntax 'llfd $x>&-' doesn't work, but I guess this
will do.


On Tue, Feb 12, 2013 at 11:12 AM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:

> On Tue, Feb 12, 2013 at 11:07:06AM -0500, Matei David wrote:
> > On a different but related note, I hate having to do eval to manipulate
> an
> > fd stored in a variable. Why doesn't 'llfd $x>&-' work, especially since
> > 'llfd >&$x' works just fine... so by the time >& is handled, the variable
> > substitutions seem to be done already.
>
>       Each redirection that may be preceded by a file descriptor number may
>       instead be preceded by a word of the form {varname}.  In this case,
>       for each redirection operator except >&- and <&-, the shell will
>       allocate a file descriptor greater than 10 and assign it to varname.
>       If >&- or <&- is preceded by {varname}, the value of varname defines
>       the file descriptor to close.
>
> This was added in Bash 4.1.
>


reply via email to

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