Skip to content

Commit c2bbcd0

Browse files
authored
Merge pull request #1 from chaosdorf/set
Add more set options.
2 parents 723abaf + e5f657c commit c2bbcd0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

bin/backup

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/bin/sh
2-
set -e
3-
[ -z "${BACKUP_NAME}" ] && { echo "error: BACKUP_NAME not set"; exit 1; }
4-
[ -z "${BACKUP_GPG_KEY_ID}" ] && { echo "error: BACKUP_GPG_KEY_ID not set"; exit 1; }
5-
[ -z "${BACKUP_SSH_DESTINATION}" ] && { echo "error: BACKUP_SSH_DESTINATION not set"; exit 1; }
2+
set -e # Exit if a command exists with an error.
3+
set -o pipefail # If any command in a pipe exits with an error, treat the whole pipe as failed.
4+
set -u # Fail if a variable is used, but not defined.
5+
[ -z "${BACKUP_NAME:-}" ] && { echo "error: BACKUP_NAME not set"; exit 1; }
6+
[ -z "${BACKUP_GPG_KEY_ID:-}" ] && { echo "error: BACKUP_GPG_KEY_ID not set"; exit 1; }
7+
[ -z "${BACKUP_SSH_DESTINATION:-}" ] && { echo "error: BACKUP_SSH_DESTINATION not set"; exit 1; }
68
BACKUP_INTERVAL=${BACKUP_INTERVAL:-1h}
79
BACKUP_SSH_REMOTE_DIRECTORY=${BACKUP_SSH_REMOTE_DIRECTORY:-backup}
810

0 commit comments

Comments
 (0)