reproduce-devel
[Top][All Lists]
Advanced

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

[task #15996] bash options: -u and -o pipefail


From: Boud Roukema
Subject: [task #15996] bash options: -u and -o pipefail
Date: Thu, 24 Jun 2021 16:33:22 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0

URL:
  <https://savannah.nongnu.org/task/?15996>

                 Summary: bash options: -u and -o pipefail
                 Project: Maneage
            Submitted by: boud
            Submitted on: 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
         Discussion Lock: Any
                  Effort: 0.00

    _______________________________________________________

Details:

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:


-u Treat unset variables as an error when substituting.


and


-o
             pipefail     the return value of a pipeline is the status of
                           the last command to exit with a non-zero status,
                           or zero if no command exited with a non-zero
status


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.

[1] https://octodon.social/@eptf/105080666953522366





    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/task/?15996>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/




reply via email to

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