From 65a838d69a5c7c9d807bed1ec813f1674abeecac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Tue, 19 Sep 2017 13:27:37 +0200 Subject: [PATCH] Fix shell location / finding POSIX says a bourne shell is available in `/bin/sh`. For any other command, `/usr/bin/env` can be used to locate the binary in $PATH. Fix all scripts to use `/bin/sh` when applicable, and rely on `/usr/bin/env` to locate `bash` when necessary. --- autogen.sh | 2 +- src/try | 2 +- tests/test-augtool-empty-line.sh | 2 +- tests/test-augtool-modify-root.sh | 2 +- tests/test-augtool.sh | 2 +- tests/test-bug-1.sh | 2 +- tests/test-events-saved.sh | 2 +- tests/test-get.sh | 2 +- tests/test-idempotent.sh | 2 +- tests/test-interpreter.sh | 2 +- tests/test-nonwritable.sh | 4 ++-- tests/test-preserve.sh | 2 +- tests/test-put-mount-augnew.sh | 4 ++-- tests/test-put-mount-augsave.sh | 4 ++-- tests/test-put-mount.sh | 4 ++-- tests/test-put-symlink-augnew.sh | 2 +- tests/test-put-symlink-augsave.sh | 2 +- tests/test-put-symlink-augtemp.sh | 2 +- tests/test-put-symlink.sh | 2 +- tests/test-save-empty.sh | 2 +- tests/test-save-mode.sh | 2 +- tests/test-unlink-error.sh | 2 +- tests/test-valgrind.sh | 6 +++--- 23 files changed, 29 insertions(+), 29 deletions(-) diff --git a/autogen.sh b/autogen.sh index 8170ea3ca..24f864e6b 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Run this to generate all the initial makefiles, etc. usage() { diff --git a/src/try b/src/try index be187655c..f82656148 100755 --- a/src/try +++ b/src/try @@ -1,4 +1,4 @@ -#! /bin/bash +#!/usr/bin/env bash topdir=$(cd $(dirname $0)/.. && pwd) export AUGEAS_LENS_LIB=${topdir}/lenses diff --git a/tests/test-augtool-empty-line.sh b/tests/test-augtool-empty-line.sh index 270ce21ea..b16652453 100755 --- a/tests/test-augtool-empty-line.sh +++ b/tests/test-augtool-empty-line.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # Test for BZ 566844. Make sure we don't spew nonsense when the input # contains empty lines diff --git a/tests/test-augtool-modify-root.sh b/tests/test-augtool-modify-root.sh index 4c92c83a1..86c94c0dc 100755 --- a/tests/test-augtool-modify-root.sh +++ b/tests/test-augtool-modify-root.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # Make sure changing the value of root works diff --git a/tests/test-augtool.sh b/tests/test-augtool.sh index 560cbf57a..8b846a644 100755 --- a/tests/test-augtool.sh +++ b/tests/test-augtool.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh TOP_DIR=$(cd $(dirname $0)/.. && pwd) TOP_BUILDDIR="$abs_top_builddir" diff --git a/tests/test-bug-1.sh b/tests/test-bug-1.sh index dda29d2ae..c8eab0307 100755 --- a/tests/test-bug-1.sh +++ b/tests/test-bug-1.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # Test for bug https://fedorahosted.org/augeas/ticket/1 # diff --git a/tests/test-events-saved.sh b/tests/test-events-saved.sh index 0e90f5ec1..c26f81264 100755 --- a/tests/test-events-saved.sh +++ b/tests/test-events-saved.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # Check that saving preserves mode and ownership; for this test to make # much sense (if any) the user running it should have at least one diff --git a/tests/test-get.sh b/tests/test-get.sh index 9fc077a5c..495cb4759 100755 --- a/tests/test-get.sh +++ b/tests/test-get.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # Check that reading the files in tests/root/ with augtool does not lead to # any errors diff --git a/tests/test-idempotent.sh b/tests/test-idempotent.sh index 03080abcf..6298a78ed 100755 --- a/tests/test-idempotent.sh +++ b/tests/test-idempotent.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # Test that saving changes that don't really change the underlying file # leave the original file intact diff --git a/tests/test-interpreter.sh b/tests/test-interpreter.sh index 303beb88f..932a430f0 100755 --- a/tests/test-interpreter.sh +++ b/tests/test-interpreter.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # Run test modules that make sure the interpreter fails/succeeds in # various hairy situations. diff --git a/tests/test-nonwritable.sh b/tests/test-nonwritable.sh index 2f669744d..5d982adef 100755 --- a/tests/test-nonwritable.sh +++ b/tests/test-nonwritable.sh @@ -1,10 +1,10 @@ -#! /bin/bash +#!/bin/sh # Test that an attempt to save into a non-writable file does not leave a # temporary file behind. # See https://github.com/hercules-team/augeas/issues/479 -if [ $UID -ne 0 -o "$(uname -s)" != "Linux" ]; then +if [ "$UID" != 0 -o "$(uname -s)" != "Linux" ]; then echo "Test can only be run as root on Linux as it uses chattr" exit 77 fi diff --git a/tests/test-preserve.sh b/tests/test-preserve.sh index a6e831203..40b86893d 100755 --- a/tests/test-preserve.sh +++ b/tests/test-preserve.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # Check that saving preserves mode and ownership; for this test to make # much sense (if any) the user running it should have at least one diff --git a/tests/test-put-mount-augnew.sh b/tests/test-put-mount-augnew.sh index cb95bdacd..5e4771e19 100755 --- a/tests/test-put-mount-augnew.sh +++ b/tests/test-put-mount-augnew.sh @@ -1,11 +1,11 @@ -#! /bin/bash +#!/bin/sh # Test that we can write into a bind mount placed at PATH.augnew with the # copy_if_rename_fails flag. # This requires that EXDEV or EBUSY is returned from rename(2) to activate the # code path, so set up a bind mount on Linux. -if [ $UID -ne 0 -o "$(uname -s)" != "Linux" ]; then +if [ "$UID" != 0 -o "$(uname -s)" != "Linux" ]; then echo "Test can only be run as root on Linux to create bind mounts" exit 77 fi diff --git a/tests/test-put-mount-augsave.sh b/tests/test-put-mount-augsave.sh index 31fcfca6b..ffa9c6ab2 100755 --- a/tests/test-put-mount-augsave.sh +++ b/tests/test-put-mount-augsave.sh @@ -1,10 +1,10 @@ -#! /bin/bash +#!/bin/sh # Test that we don't follow bind mounts when writing to .augsave. # This requires that EXDEV or EBUSY is returned from rename(2) to activate the # code path, so set up a bind mount on Linux. -if [ $UID -ne 0 -o "$(uname -s)" != "Linux" ]; then +if [ "$UID" != 0 -o "$(uname -s)" != "Linux" ]; then echo "Test can only be run as root on Linux to create bind mounts" exit 77 fi diff --git a/tests/test-put-mount.sh b/tests/test-put-mount.sh index 210bc10ac..8ee0a6d28 100755 --- a/tests/test-put-mount.sh +++ b/tests/test-put-mount.sh @@ -1,10 +1,10 @@ -#! /bin/bash +#!/bin/sh # Test that we can write into a bind mount with the copy_if_rename_fails flag. # This requires that EXDEV or EBUSY is returned from rename(2) to activate the # code path, so set up a bind mount on Linux. -if [ $UID -ne 0 -o "$(uname -s)" != "Linux" ]; then +if [ "$UID" != 0 -o "$(uname -s)" != "Linux" ]; then echo "Test can only be run as root on Linux to create bind mounts" exit 77 fi diff --git a/tests/test-put-symlink-augnew.sh b/tests/test-put-symlink-augnew.sh index e87fb63f4..c14884923 100755 --- a/tests/test-put-symlink-augnew.sh +++ b/tests/test-put-symlink-augnew.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # Test that we don't follow symlinks when writing to .augnew diff --git a/tests/test-put-symlink-augsave.sh b/tests/test-put-symlink-augsave.sh index 2f470cd3c..beefad62f 100755 --- a/tests/test-put-symlink-augsave.sh +++ b/tests/test-put-symlink-augsave.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # Test that we don't follow .augsave symlinks diff --git a/tests/test-put-symlink-augtemp.sh b/tests/test-put-symlink-augtemp.sh index 0076e6426..a20da88af 100755 --- a/tests/test-put-symlink-augtemp.sh +++ b/tests/test-put-symlink-augtemp.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # Test that we don't follow .augnew symlinks (regression test) diff --git a/tests/test-put-symlink.sh b/tests/test-put-symlink.sh index 64749eac8..b80545896 100755 --- a/tests/test-put-symlink.sh +++ b/tests/test-put-symlink.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # Test that we correctly preserve symlinks when saving a file diff --git a/tests/test-save-empty.sh b/tests/test-save-empty.sh index 847fd69d7..3ca8dddea 100755 --- a/tests/test-save-empty.sh +++ b/tests/test-save-empty.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # Test that we report an error when writing to nonexistant dirs # but that we do create new files correctly diff --git a/tests/test-save-mode.sh b/tests/test-save-mode.sh index f8a0c3b9a..843fd3f4a 100755 --- a/tests/test-save-mode.sh +++ b/tests/test-save-mode.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # Test manipulating the save flags in /augeas/save diff --git a/tests/test-unlink-error.sh b/tests/test-unlink-error.sh index 350e7ca68..a6a62afd1 100755 --- a/tests/test-unlink-error.sh +++ b/tests/test-unlink-error.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # Make sure we don't delete files simply because there was an error reading # them in diff --git a/tests/test-valgrind.sh b/tests/test-valgrind.sh index c000e4404..1e6898fe3 100755 --- a/tests/test-valgrind.sh +++ b/tests/test-valgrind.sh @@ -1,11 +1,11 @@ -#! /bin/bash +#!/bin/sh # Run the tests in lenses/tests through valgrind and report which ones leak set -e TOPDIR=$(cd $(dirname $0)/.. && pwd) -[[ -n "$top_builddir" ]] || top_builddir=$TOPDIR -[[ -n "$top_srcdir" ]] || top_srcdir=$TOPDIR +[ -n "$top_builddir" ] || top_builddir=$TOPDIR +[ -n "$top_srcdir" ] || top_srcdir=$TOPDIR AUGPARSE="libtool --mode=execute valgrind -q --leak-check=full ${top_builddir}/src/augparse"