diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-22 15:45:02 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-22 15:45:02 -0700 |
| commit | 0d4f2e45bcb153921612963bfd306b976a4828ae (patch) | |
| tree | 0e390809284b4d04085f387f1357016fa17c03e7 | |
| parent | addac10a47693a976808bf75fe63aed19f8dbb63 (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-x | nomsu | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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:" |
