aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-07-24 14:46:56 +0000
committermerakor <cem@ckyln.com>2020-07-24 14:46:56 +0000
commite45368d0ea858c5ac2266df7301cf7c7c379d953 (patch)
tree4d4edb7e3128157c9355a19b24ca1b80929ab484 /src
parent3bbb028b00fafc5c0d5e47c96e21a61ef5e842ac (diff)
downloadcpt-e45368d0ea858c5ac2266df7301cf7c7c379d953.tar.gz
cpt: don't apply globs when using main tools
FossilOrigin-Name: 9f0e0f0114a2017e0557017666cce5a92d38a9d0938177edc56c75515df39188
Diffstat (limited to 'src')
-rwxr-xr-xsrc/cpt28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/cpt b/src/cpt
index a2dad72..b3081f9 100755
--- a/src/cpt
+++ b/src/cpt
@@ -1,7 +1,10 @@
#!/bin/sh -ef
# shellcheck disable=1091
-if command -v cpt-lib >/dev/null; then . cpt-lib; else ./cpt-lib; fi
+if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi
+
+# If none of the tools below are specified, we will reenable glob
+unset glob
[ "$1" ] && { arg=$1; shift; }
case "$arg" in
@@ -26,19 +29,20 @@ case "$arg" in
--version|-v|version) version ;;
# Reserve these arguments for the following tools.
- a) arg=alternatives ;;
- b) arg=build ;;
- c) arg=checksum ;;
- d) arg=download ;;
- f) arg=fetch ;;
- i) arg=install ;;
- l) arg=list ;;
- r) arg=remove ;;
- s) arg=search ;;
- u) arg=update ;;
+ a|alternatives) arg=alternatives ;;
+ b|build) arg=build ;;
+ c|checksum) arg=checksum ;;
+ d|download) arg=download ;;
+ f|fetch) arg=fetch ;;
+ i|install) arg=install ;;
+ l|list) arg=list ;;
+ r|remove) arg=remove ;;
+ s|search) arg=search ;;
+ u|update) arg=update ;;
+ *) glob=1 ;;
esac
-util=$(SEARCH_PATH=$PATH pkg_find "cpt-$arg"* "" -x 2>/dev/null) ||
+util=$(SEARCH_PATH=$PATH pkg_find "cpt-$arg${glob:+*}" "" -x 2>/dev/null) ||
die "'cpt $arg' is not a valid command"
"$util" "$@"