summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-04-11 14:29:16 -0400
committerNick Mathewson <nickm@torproject.org>2019-04-11 14:29:16 -0400
commitd549440124be04986cc7a2b8cb98bd878fca5532 (patch)
treed400a27b98be7313652292fe709e873aa36fb1cb
parentf8dc935fb7f2d5fb2a5ec4224c7d99f0f177608e (diff)
parentb2eced6c0747159ab7b3942a45c1a147a5ecfc96 (diff)
downloadtor-d549440124be04986cc7a2b8cb98bd878fca5532.tar.gz
tor-d549440124be04986cc7a2b8cb98bd878fca5532.zip
Merge remote-tracking branch 'tor-github/pr/887'
-rw-r--r--changes/bug300022
-rwxr-xr-xsrc/test/test_key_expiration.sh14
2 files changed, 9 insertions, 7 deletions
diff --git a/changes/bug30002 b/changes/bug30002
new file mode 100644
index 0000000000..da61c9e4b2
--- /dev/null
+++ b/changes/bug30002
@@ -0,0 +1,2 @@
+ o Code simplification and refactoring (shell scripts):
+ - Fix shellcheck warnings in test_key_expiration.sh. Resolves issue 30002.
diff --git a/src/test/test_key_expiration.sh b/src/test/test_key_expiration.sh
index cf6608634d..1ed81c81c7 100755
--- a/src/test/test_key_expiration.sh
+++ b/src/test/test_key_expiration.sh
@@ -6,14 +6,14 @@
umask 077
set -e
-if [ $# -eq 0 ] || [ ! -f ${1} ] || [ ! -x ${1} ]; then
+if [ $# -eq 0 ] || [ ! -f "${1}" ] || [ ! -x "${1}" ]; then
if [ "$TESTING_TOR_BINARY" = "" ] ; then
echo "Usage: ${0} PATH_TO_TOR [case-number]"
exit 1
fi
fi
-UNAME_OS=`uname -s | cut -d_ -f1`
+UNAME_OS=$(uname -s | cut -d_ -f1)
if test "$UNAME_OS" = 'CYGWIN' || \
test "$UNAME_OS" = 'MSYS' || \
test "$UNAME_OS" = 'MINGW'; then
@@ -47,11 +47,11 @@ dump() { xxd -p "$1" | tr -d '\n '; }
die() { echo "$1" >&2 ; exit 5; }
check_dir() { [ -d "$1" ] || die "$1 did not exist"; }
check_file() { [ -e "$1" ] || die "$1 did not exist"; }
-check_no_file() { [ -e "$1" ] && die "$1 was not supposed to exist" || true; }
-check_files_eq() { cmp "$1" "$2" || die "$1 and $2 did not match: `dump $1` vs `dump $2`"; }
+check_no_file() { if [ -e "$1" ]; then die "$1 was not supposed to exist"; fi }
+check_files_eq() { cmp "$1" "$2" || die "$1 and $2 did not match: $(dump "$1") vs $(dump "$2")"; }
check_keys_eq() { check_files_eq "${SRC}/keys/${1}" "${ME}/keys/${1}"; }
-DATA_DIR=`mktemp -d -t tor_key_expiration_tests.XXXXXX`
+DATA_DIR=$(mktemp -d -t tor_key_expiration_tests.XXXXXX)
if [ -z "$DATA_DIR" ]; then
echo "Failure: mktemp invocation returned empty string" >&2
exit 3
@@ -60,10 +60,10 @@ if [ ! -d "$DATA_DIR" ]; then
echo "Failure: mktemp invocation result doesn't point to directory" >&2
exit 3
fi
-trap "rm -rf '$DATA_DIR'" 0
+trap 'rm -rf "$DATA_DIR"' 0
# Use an absolute path for this or Tor will complain
-DATA_DIR=`cd "${DATA_DIR}" && pwd`
+DATA_DIR=$(cd "${DATA_DIR}" && pwd)
touch "${DATA_DIR}/empty_torrc"