From c5c361be0c44798d4ac151d749fa4ebbbd0161f9 Mon Sep 17 00:00:00 2001 From: rugk Date: Thu, 20 Jul 2017 00:23:59 +0200 Subject: [PATCH] Fix bashism in shell scripts (#2820) Fix bashism in shell scripts, also fixes #2816 This makes the scripts fully POSIX-compatible. Used shellcheck to check. --- .travis/upload_coverage.sh | 2 +- docs/quickstart.rst | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis/upload_coverage.sh b/.travis/upload_coverage.sh index 03475fc9c..d0b545244 100755 --- a/.travis/upload_coverage.sh +++ b/.travis/upload_coverage.sh @@ -4,7 +4,7 @@ set -e set -x NO_COVERAGE_TOXENVS=(pep8) -if ! [[ "${NO_COVERAGE_TOXENVS[*]}" =~ "${TOXENV}" ]]; then +if ! [[ "${NO_COVERAGE_TOXENVS[*]}" =~ ${TOXENV} ]]; then source ~/.venv/bin/activate # on osx, tests run as root, need access to .coverage sudo chmod 666 .coverage diff --git a/docs/quickstart.rst b/docs/quickstart.rst index d816fea00..597929eac 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -90,8 +90,8 @@ backed up and that the ``prune`` command is keeping and deleting the correct bac export BORG_PASSCOMMAND='pass show backup' # some helpers and error handling: - function info () { echo -e "\n"`date` $@"\n" >&2; } - trap "echo `date` Backup interrupted >&2; exit 2" SIGINT SIGTERM + info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; } + trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM info "Starting backup" @@ -135,7 +135,8 @@ backed up and that the ``prune`` command is keeping and deleting the correct bac prune_exit=$? - global_exit=$(( ${backup_exit} > ${prune_exit} ? ${backup_exit} : ${prune_exit} )) + # use highest exit code as global exit code + global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit )) if [ ${global_exit} -eq 1 ]; then