Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15000

[IDEA] more granular shell options to fix errexit

From Ivan Pozdeev <vano@mail.mipt.ru>
Newsgroups gnu.bash.bug
Subject [IDEA] more granular shell options to fix errexit
Date 2018-12-29 07:23 +0300
Message-ID <mailman.6497.1546063477.1284.bug-bash@gnu.org> (permalink)

Show all headers | View raw


With the recent inherit_errexit , the Bash team seems to have finally 
bumped into a workable way to fix errexit which has been broken for 
decades (https://mywiki.wooledge.org/BashFAQ/105).

Instead of trying to invent a replacement shell option for that and hope 
to get it right on the first try (that errexit failed to), make granular 
options that would each change a single thing -- and see which of them 
pass the test of time.

The following suggested options aim to eliminate all cases that still 
exist, outlined on the above link, where an exit code of a command is 
swallowed/ignored.

* Do not unset `-e' inside a "checked command": only use the logic in 
the "The shell does not exit" clause when checking the exit code of the 
checked command, as a unit.

    (I would argue that this is the intended POSIX semantic in the first 
place but I guess I'm about 25 years late to the party.)
    Suggested option name: preserve_errexit

* If a command substitution fails, fail the containing command. 
Suggested name: cmdsubstfail

* Same for process substitution. Fail the command the same way as a 
pipeline with pipefail (and either only if pipefail is set, or imply 
pipefail). Suggested name: prsubstfail

(Probably the same for history expansion. I don't use it so have no 
opinion here.)

I don't have an opinion if they should be shell options or `shopt' 
options -- no differences to speak of in my book.

-- 
Regards,
Ivan

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

[IDEA] more granular shell options to fix errexit Ivan Pozdeev <vano@mail.mipt.ru> - 2018-12-29 07:23 +0300

csiph-web