Skip to content

Commit 1f641f6

Browse files
committed
Check exit status directly in install script
The "template" installation script stored in this repository checks for an existing installation in the PATH in order to provide appropriate advice to the user about adding the installation to their their PATH environment variable. This check is done by checking the exit status of `command -v`. The previous use of `$?` for that check was unnecessary since the command itself can be checked. This change is required for compliance with ShellCheck rule SC2181: https://github.com/koalaman/shellcheck/wiki/SC2181
1 parent 45b0ef0 commit 1f641f6

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

other/installation-script/install.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ bye() {
186186

187187
testVersion() {
188188
set +e
189-
EXECUTABLE_PATH="$(command -v $PROJECT_NAME)"
190-
if [ "$?" = "0" ]; then
189+
if EXECUTABLE_PATH="$(command -v $PROJECT_NAME)"; then
191190
# Convert to resolved, absolute paths before comparison
192191
EXECUTABLE_REALPATH="$(cd -- "$(dirname -- "$EXECUTABLE_PATH")" && pwd -P)"
193192
EFFECTIVE_BINDIR_REALPATH="$(cd -- "$EFFECTIVE_BINDIR" && pwd -P)"

0 commit comments

Comments
 (0)