why does errexit exist in its current utterly useless form?

2012-12-14 Thread matei . david
I recently worked on a project involving many bash scripts, and I've been trying to use errexit to stop various parts of a script as soon as anything returns a non-0 return code. As it turns out, this is an utterly useless endeavour. In asking this question on this forum, I hope somebody out the

Re: why does errexit exist in its current utterly useless form?

2012-12-15 Thread matei . david
On Friday, December 14, 2012 6:23:41 PM UTC-5, Eric Blake wrote: > Short answer: historical compatibility. 'set -e' has been specified to > behave the way it did 30 years ago in one reference implementation, and > while you can argue till you are blue in the face that the reference > implementatio

Re: why does errexit exist in its current utterly useless form?

2012-12-15 Thread matei . david
On Saturday, December 15, 2012 5:23:04 PM UTC-5, Chet Ramey wrote: > There is already a proposal for a new option similar to what you want; you > can read the discussion at > > http://austingroupbugs.net/view.php?id=537 Thank you for all the references, I'll have a look!

eval doesn't close file descriptor?

2013-02-11 Thread matei . david
With the script below, I'd expect any fd pointing to /dev/null to be closed when the second llfd() is executed. Surprisingly, fd 3 is closed, but fd 10 is now open, pointing to /dev/null, as if eval copied it instead of closing it. Is this a bug? Thanks, M $ bash -c 'llfd () { ls -l /proc/$BA

Re: eval doesn't close file descriptor?

2013-02-12 Thread Matei David
Ok, but I see the same behaviour when eval runs in a subshell: $ bash -c 'llfd () { echo "pid:$BASHPID" >&2; ls -l /proc/$BASHPID/fd/ >&2; }; x=3; eval "exec $x>/dev/null"; llfd; echo | eval "llfd $x>&-"' [same output, fd 10 open, pointing to /dev/null, even though it's a subshell] $ bash -c 'llf

Re: eval doesn't close file descriptor?

2013-02-12 Thread Matei David
hy 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 wrote: > On Tue, Feb 12, 2013 at 11:07:06AM -0500, Matei David wrote: > > On a d

Re: eval doesn't close file descriptor?

2013-02-12 Thread Matei David
hich are not copied across subshells; like 60&63 3. fds which are copied across subshells, but not exec; like 10 I knew about types 1&2, but not about type 3. Apparently with your first suggestion, fd 10 is created and survives a subshell creation. Is this correct?? On Tue, Feb 12, 20

Re: eval doesn't close file descriptor?

2013-02-12 Thread Matei David
o on this subject. Thanks, M On Tue, Feb 12, 2013 at 2:50 PM, Chet Ramey wrote: > On 2/12/13 2:07 PM, Matei David wrote: > > > ... there seem to be not 2 but 3(!) types of file descriptors: > > 1. fds which are copied across both subshells and exec; like 4 > > 2. fds wh

Re: eval doesn't close file descriptor?

2013-02-13 Thread Matei David
Thank you for the explanation. On Tue, Feb 12, 2013 at 8:32 PM, Chet Ramey wrote: > On 2/12/13 11:40 AM, Pierre Gaston wrote: > > On Tue, Feb 12, 2013 at 6:07 PM, Matei David > wrote: > > > >> Ok, but I see the same behaviour when eval runs in a subshell: > >

Re: eval doesn't close file descriptor?

2013-02-13 Thread Matei David
2:28 8 -> /proc/4520/auxv cat: /dev/fd/63: No such file or directory $ Note how 63 is open before '(echo)' and closed after. Is this expected? On Wed, Feb 13, 2013 at 12:06 PM, Matei David wrote: > Thank you for the explanation. > > > On Tue, Feb 12, 2013 at 8:32 PM, Ch