aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2021-02-04 23:53:27 +0000
committermerakor <cem@ckyln.com>2021-02-04 23:53:27 +0000
commit08b2a230703d55f331458d3bedaba715948426a8 (patch)
treef988f2397a22e3d4d8f3643804bf60374f9f37dd
parenta75dae07e41e8220ae35d726673ecc7ca0520476 (diff)
downloadcpt-08b2a230703d55f331458d3bedaba715948426a8.tar.gz
cpt-alternatives: use getoptions parser so that global options are recognized
FossilOrigin-Name: 1cb9a4e4a9b69ba0dd91f48ff1100587dc6ffb9b9fed7e060f838672f1294473
-rwxr-xr-xsrc/cpt-alternatives18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/cpt-alternatives b/src/cpt-alternatives
index e21b6c9..c4c7726 100755
--- a/src/cpt-alternatives
+++ b/src/cpt-alternatives
@@ -1,21 +1,21 @@
#!/bin/sh -ef
# List and swap to alternatives
+parser_definition() {
+ setup REST help:usage -- "usage: ${0##*/} [-] [package file]"
+ global_options
+}
+
if [ -f ./cpt-lib ]; then . ./cpt-lib; else . cpt-lib; fi
-case "$1" in --version|--help|-v|-h|'') ;; *)
- [ -w "$CPT_ROOT/" ] || [ "$uid" = 0 ] || {
+# We don't need to be root in order to list alternatives, so skip privilege
+# elevation if no arguments are passed to the script.
+[ -z "$1" ] || [ -w "$CPT_ROOT/" ] || [ "$uid" = 0 ] || {
as_root "$0" "$@"
exit $?
- }
-esac
+}
case "$1" in
- --help|-h)
- out "usage: ${0##*/} [-] [pkg file]"
- exit 0
- ;;
- --version|-v) version ;;
-)
while read -r pkg path; do
pkg_swap "$pkg" "$path"