[Top][All Lists]

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

Re: Equivalent of ksh, zsh {N}<[WORD] ?

From: R. Bernstein
Subject: Re: Equivalent of ksh, zsh {N}<[WORD] ?
Date: Tue, 26 Aug 2008 20:07:23 -0400

Chet Ramey writes:
 > >   Redirections using file descriptors greater than 9 should be used with
 > >   care, as they may conflict with file descriptors the shell uses
 > >   internally.
 > The sentence is more a caution about the previously-mentioned clexec bugs.
 > As a practical matter, you should be able to use fds over 20 without
 > problems, but that is not portable across shells.

Okay. I suppose then that sentence should be rewritten in light of the
clexec bug fixes. As is, it can be read as discouragement to using
file descriptors greater than 9.

 > You should not need to know what fds bash is using, nor what is "free" to
 > use -- the idea is that bash will take care of saving and restoring file
 > descriptors when it needs to.  The requirement to know what file
 > descriptors you have open is new and not easily satisfied by the existing
 > redirections.

So you've then just given a good reason why the form {n}<[word] is
desirable. Yes, a programmer does not really want to manage file
descriptors but would prefer bash to handle that. But because you
can't currently ask bash to select one and give back some sort of
object that can be used in a read, the only other good alternative is
for the programmer to use something like lsof of look at the process
table to figure out what's in use. 

And the standard C libraries also work like {n}<[word] works
also. When you open, the C library selects the descriptor and returns

reply via email to

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