aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-22 15:45:02 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-22 15:45:02 -0700
commit0d4f2e45bcb153921612963bfd306b976a4828ae (patch)
tree0e390809284b4d04085f387f1357016fa17c03e7
parentaddac10a47693a976808bf75fe63aed19f8dbb63 (diff)
Updated launcher script to use `find` istead of `ls` and `grep`, and to
use "$(...)" instead of eval "$(...)", as per best practice recommendations.
-rwxr-xr-xnomsu8
1 files changed, 4 insertions, 4 deletions
diff --git a/nomsu b/nomsu
index dbeee11..6458c3c 100755
--- a/nomsu
+++ b/nomsu
@@ -1,15 +1,15 @@
#!/bin/bash
while getopts ':V:L' flag; do
case "${flag}" in
- V) VERSION="${OPTARG/./\.}\\b" ;;
+ V) VERSION=$OPTARG ;;
L) LIST="YES" ;;
esac
done
if [[ $VERSION ]]; then
- candidates=$(ls $(dirname $BASH_SOURCE) | grep "^nomsu$VERSION[0-9.]*$")
+ candidates=$(find $(dirname $BASH_SOURCE) -maxdepth 1 -name "nomsu$VERSION*")
else
- candidates=$(ls $(dirname $BASH_SOURCE) | grep "^nomsu[0-9.]\+$")
+ candidates=$(find $(dirname $BASH_SOURCE) -maxdepth 1 -name "nomsu[0-9]*")
fi
if [[ $LIST ]]; then
@@ -18,7 +18,7 @@ if [[ $LIST ]]; then
fi
if [[ $candidates ]]; then
- eval $(dirname $BASH_SOURCE)/$(echo "$candidates" | sort -V | tail -n 1) $@
+ "$(echo "$candidates" | sort -V | tail -n 1)" "$@"
else
echo "Failed to find a Nomsu version matching the regex: \"nomsu$VERSION\""
echo "The versions available are:"