help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Option execfail does not work in subshells


From: R. Diez
Subject: Re: [Help-bash] Option execfail does not work in subshells
Date: Wed, 9 Aug 2017 14:43:45 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1



I had to look at the source. Subshells are specifically exempted from the
execfail settings. It's been this way for at least 24 years, so the exact
reason is lost to time.

Thanks for looking. I could almost forgive your wrong answer yesterday. }8-)

I am writing a shell script which needs execfail to work in a subshell, specifically when starting a background process with & . The reason is, I want to print a proper error message when the user passes the wrong command (for example), but I could think of other actions, like logging the failure somewhere.

There does not seem to be a valid reason for execfail to not work in a subshell. Should I create a bug for this? (I am assuming that there is a public bug tracker for Bash).

There is one other thing that I noticed. When the 'exec' calls redirects stdout and stderr, they remain redirected after 'exec' fails. I resorted to saving and restoring their file descriptors in this scenario. However, I think that this fact should be clearly documented, because, at the moment, after reading the docs you tend to believe that such a permanent redirection should only be the case if you specify no command to run in the 'exec' calls.

In any case, I wonder what other things do not get restored properly after 'exec' fails.

Regards,
  rdiez



reply via email to

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