Browse Source

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.
rugk 8 years ago
parent
commit
c5c361be0c
2 changed files with 5 additions and 4 deletions
  1. 1 1
      .travis/upload_coverage.sh
  2. 4 3
      docs/quickstart.rst

+ 1 - 1
.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

+ 4 - 3
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