cylc / cylc-doc

Documentation (User Guide, Cheat Sheets, etc.) for the Cylc Workflow Engine.
https://cylc.github.io/cylc-doc/
GNU General Public License v3.0
8 stars 18 forks source link

Make the "Use `set -euo pipefail` in Bash scripts" recommendation less ambiguous #728

Closed elliotfontaine closed 1 month ago

elliotfontaine commented 1 month ago

In Basic Principles of the Workflow Design Guide, the following recommandations are given:

  • In shell scripts use set -u to abort on any reference to an undefined variable. If you really need an undefined variable to evaluate to an empty string, make it explicit: FOO=${FOO:-}.
  • In shell scripts use set -e to abort on any error without having to failure-check each command explicitly.
  • In shell scripts use set -o pipefail to abort on any error within a pipe line. Note that all commands in the pipe line will still run, it will just exit with the right most non-zero exit status.

Obviously this would refer to bash scripts that are called like:

[runtime]
    [[some_task]]
        script = mybashscript.sh

And not bash code inlined directly in a task script item, since the given recommandations are there by default.

There is nothing false in the way it is currently phrased, but it could be made unambiguous by referencing the Task Implementation part of the documentation.