Skip to content

Commit

Permalink
Use POSIX standard technique for testing existance of a command
Browse files Browse the repository at this point in the history
Fixes issue #73.

macOS dirname does not have a `--version` option, which was making the script fail on macOS.

This technique should be POSIX compliant and more crossplatform.

Solution taken from:

https://stackoverflow.com/questions/592620/how-can-i-check-if-a-program-exists-from-a-bash-script
  • Loading branch information
seanm authored and dzenanz committed Aug 27, 2024
1 parent 2ded007 commit 4e78ffa
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Utilities/updateBoost.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ die()
## Validate ##
required_commands=( git grep dirname basename cat )
for required_command in ${required_commands[@]}; do
$required_command --version >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
die "Command \"$required_command\" not found"
if ! command -v $required_command &> /dev/null; then
die "Command \"$required_command\" not found"
fi
done

Expand Down

0 comments on commit 4e78ffa

Please sign in to comment.