From e04d6b7bf58a95105a8fc79fcde7c0e98875e72a Mon Sep 17 00:00:00 2001 From: a1346054 <36859588+a1346054@users.noreply.github.com> Date: Tue, 13 Sep 2022 18:42:15 +0000 Subject: tests: directly test for presence of command Test directly for presence of command instead of indirectly testing the return code. Additionally: * uses a shell builtin `command -v` instead of external `which` * `command -v` is the standardized version of `which` --- test/environment/environment.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'test/environment') diff --git a/test/environment/environment.sh b/test/environment/environment.sh index da9c170b9..f6acada73 100755 --- a/test/environment/environment.sh +++ b/test/environment/environment.sh @@ -39,8 +39,7 @@ echo "TESTING: environment variables (test/environment/env.exp)" echo "TESTING: firejail in firejail - single sandbox (test/environment/firejail-in-firejail.exp)" ./firejail-in-firejail.exp -which aplay 2>/dev/null -if [ "$?" -eq 0 ] && [ "$(aplay -l | grep -c "List of PLAYBACK")" -gt 0 ]; +if command -v aplay && [ "$(aplay -l | grep -c "List of PLAYBACK")" -gt 0 ]; then echo "TESTING: sound (test/environment/sound.exp)" ./sound.exp @@ -54,8 +53,7 @@ echo "TESTING: nice (test/environment/nice.exp)" echo "TESTING: quiet (test/environment/quiet.exp)" ./quiet.exp -which strace 2>/dev/null -if [ "$?" -eq 0 ]; +if command -v strace then echo "TESTING: --allow-debuggers (test/environment/allow-debuggers.exp)" ./allow-debuggers.exp @@ -67,8 +65,7 @@ fi # $ sudo apt-get install ibus-table-array30 # $ ibus-setup -find ~/.config/ibus/bus | grep unix-0 -if [ "$?" -eq 0 ]; +if find ~/.config/ibus/bus | grep unix-0 then echo "TESTING: ibus (test/environment/ibus.exp)" ./ibus.exp -- cgit v1.2.3-54-g00ecf