Top > Shell

ノウハウ

!/usr/bin/env bash
set -euo pipefail

“set -e” which ensures that your script stops on first command failure. By default, when a command fails, BASH executes the next command. Looking at the logs, you might feel that the script executed successfully while some commands might have failed. Caveat: Be careful about applying it to existing scripts.

“set -u” which ensures that your script exits on the first unset variable encountered. Otherwise, bash replaces the unset variables with empty default values.

“set -o pipefail” which ensures that if any command in a set of piped commands failed, the overall exit status is the status of the failed command. Othe


Reload   Diff   Front page List of pages Search Recent changes Backup Referer   Help   RSS of recent changes
Last-modified: Tue, 12 Dec 2023 19:18:45 JST (129d)