From 9cdb80efe673152f90adba24fb2248532c2a637e Mon Sep 17 00:00:00 2001 From: merakor Date: Thu, 20 Aug 2020 11:47:16 +0000 Subject: cpt: use 'getopt' for option parsing FossilOrigin-Name: 65f22dd80a83335174c541e38f6b4c2c870e813faa587d06ed8989b50018fc09 --- src/cpt-search | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/cpt-search') diff --git a/src/cpt-search b/src/cpt-search index 47faaf7..7eaffb9 100755 --- a/src/cpt-search +++ b/src/cpt-search @@ -8,15 +8,19 @@ if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi # in order to only find the first instance of a package. all=1 -case "$1" in - --help|-h|'') - out "usage: ${0##*/} [--single] [pkg...]" "" \ - " Options:" \ - " --single Only show the first instance of a package" "" - exit 0 - ;; - --version|-v) version ;; - --single) unset all; shift ;; -esac +eval set -- "$(getopt -l single,version,help -- shv "$@")" +while :; do + case "$1" in + --help|-h|'') + out "usage: ${0##*/} [--single] [pkg...]" "" \ + " Options:" \ + " -s --single Only show the first instance of a package" "" + exit 0 + ;; + --version|-v) version ;; + --single|-s) unset all; shift ;; + --) shift; break ;; + esac +done for pkg; do pkg_find "$pkg" "${all:+all}"; done -- cgit v1.2.3