Maneage - Tasks: task #15996, bash options: -u and -o pipefail
You are not allowed to post comments on this tracker with your current authentication level.
task #15996: bash options: -u and -o pipefail
Submitter: | Boud Roukema <boud> | ||
Submitted: | Thu 24 Jun 2021 08:33:20 PM UTC | ||
Should Start On: | Thu 24 Jun 2021 12:00:00 AM UTC | Should be Finished on: | Thu 24 Jun 2021 12:00:00 AM UTC |
Category: | None | Priority: | 5 - Normal |
Status: | None | Privacy: | Public |
Percent Complete: | 0% | Assigned to: | None |
Open/Closed: | Open | Effort: | 0.00 |
Sat 26 Jun 2021 12:48:05 AM UTC, comment #4: |
Boud Roukema <boud>![]() |
Fri 25 Jun 2021 11:01:49 PM UTC, comment #3: It is a good suggestion to add these flags, they are indeed very useful (and if someone doesn't like them, they can easily be dis-activated).
It would be great if you keep a branch and commit all the fixes you have found so far. In this way, when anyone else has time they can continue the work until it is complete.
Does Dash also support these options? If so, we can also have them in 'basic.mk' (because the shell of 'basic.mk' is Dash). |
Mohammad Akhlaghi <makhlaghi>![]() |
Fri 25 Jun 2021 08:43:48 PM UTC, comment #2: See https://savannah.nongnu.org/task/index.php?15997 for safe-rm , an alternative to set -u for reducing the chance of a catastrophic rm event.
|
Boud Roukema <boud>![]() |
Fri 25 Jun 2021 08:27:30 PM UTC, comment #1: The link failed in 'full markup', so here it is again: https://octodon.social/@eptf/105080666953522366 |
Boud Roukema <boud>![]() |
Thu 24 Jun 2021 08:33:20 PM UTC, original submission:
The command help set shows two potentially very useful bash options for reducing the chance of catastrophic errors (recursive remove due to an "unbound" (undefined) environment variable) and for failing a pipe if any of the pipe elements fails, rather than continuing on happily despite the error. There's a very nice explanatory cartoon at [1].
We already have 'set -x'. The other two options are:
and
I tried setting both in reproduce/software/make/high-level.mk . One easy bug which was probably OK to fix was that the cmake rule defined LIBS in terms of "$$LIBS ...". This failed with -u because LIBS was "unbound". My guess is that we don't need any external values in LIBS, so this could easily be fixed to remove the "old" $$LIBS.
However, then on a successive ./project configure --existing-conf command I got several fatal failures because of some unbound variables, apparently related to previously installed (or not yet installed?) packages.
My guess is that including both of these options in high-level.mk and initialize.mk would be useful in the long run, in addition to set -e, making the overall system more robust and secure, but some time would first have to be invested in fixing things that break as a result. Most are probably easily fixed, and probably should be fixed.
|
Boud Roukema <boud>![]() |
No files currently attached
Depends on the following items: None found
Items that depend on this one: None found
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
If I have the time to look at this in depth, I'll create a branch, but the task is open to any other volunteers... My impression was that there could be quite a few cases to handle beyond LIBS in cmake.
Dash appears to have -u , from 'info dash':
but doesn't seem to have -o pipefail .
So -u should be usable for basic.mk - but obviously will have to be tested properly first.