From 1df4ecaf961d124ab31ca74407eabd874a521403 Mon Sep 17 00:00:00 2001 From: merakor Date: Sun, 23 Aug 2020 13:25:06 +0000 Subject: getoptions: do not unset variables if parameters aren't given. FossilOrigin-Name: d3aeabb1ff9e6acaea85638e37721065bb937b2cb1a349270a5dbcb0ef669d59 --- src/cpt-build | 6 +++--- src/cpt-install | 10 +++++----- src/cpt-remove | 8 ++++---- src/cpt-update | 12 ++++++------ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/cpt-build b/src/cpt-build index d014f28..5f73de8 100755 --- a/src/cpt-build +++ b/src/cpt-build @@ -7,9 +7,9 @@ if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi parser_definition() { setup REST -- "usage: ${0##*/} [pkg...]" msg -- '' 'Options:' - flag CPT_PROMPT -y --no-prompt on:0 -- "Do not prompt for confirmation" - disp :usage -h --help -- "Show this help message" - disp :version -v --version -- "Print version information" + flag CPT_PROMPT -y --no-prompt on:0 init:"$CPT_PROMPT" -- "Do not prompt for confirmation" + disp :usage -h --help -- "Show this help message" + disp :version -v --version -- "Print version information" } eval "$(getoptions parser_definition parse "$0")" diff --git a/src/cpt-install b/src/cpt-install index 0ee6816..92d8eee 100755 --- a/src/cpt-install +++ b/src/cpt-install @@ -2,15 +2,15 @@ # Install a package # shellcheck disable=1091 -if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi +if [ -f ./cpt-lib ]; then . ./cpt-lib; else . cpt-lib; fi parser_definition() { setup REST -- "usage: ${0##*/} [pkg...]" msg -- '' 'Options:' - flag CPT_FORCE -f --force -- "Force installation" - param CPT_ROOT --root -- "Use an alternate root directory" - disp :usage -h --help -- "Show this help message" - disp :version -v --version -- "Print version information" + flag CPT_FORCE -f --force init:="$CPT_FORCE" -- "Force installation" + param CPT_ROOT --root init:="$CPT_ROOT" -- "Use an alternate root directory" + disp :usage -h --help -- "Show this help message" + disp :version -v --version -- "Print version information" } eval "$(getoptions parser_definition parse "$0")" diff --git a/src/cpt-remove b/src/cpt-remove index 7f3e64e..5462b4b 100755 --- a/src/cpt-remove +++ b/src/cpt-remove @@ -7,10 +7,10 @@ if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi parser_definition() { setup REST -- "usage: ${0##*/} [pkg...]" msg -- '' 'Options:' - flag CPT_FORCE -f --force -- "Force removal" - param CPT_ROOT --root -- "Use an alternate root directory" - disp :usage -h --help -- "Show this help message" - disp :version -v --version -- "Print version information" + flag CPT_FORCE -f --force init:"$CPT_FORCE" -- "Force removal" + param CPT_ROOT --root init:"$CPT_ROOT" -- "Use an alternate root directory" + disp :usage -h --help -- "Show this help message" + disp :version -v --version -- "Print version information" } eval "$(getoptions parser_definition parse "$0")" diff --git a/src/cpt-update b/src/cpt-update index 415353b..bbda066 100755 --- a/src/cpt-update +++ b/src/cpt-update @@ -7,12 +7,12 @@ if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi parser_definition() { setup REST -- "usage: ${0##*/} [options]" msg -- '' 'Options:' - flag download_only -d --download -- "Only download updatable packages" - flag CPT_FETCH -n --no-fetch on:0 -- "Do not refresh the repositories" - flag CPT_PROMPT -y --no-prompt on:0 -- "Do not prompt for confirmation" - param CPT_ROOT --root -- "Use an alternate root directory" - disp :usage -h --help - disp :version -v --version + flag download_only -d --download -- "Only download updatable packages" + flag CPT_FETCH -n --no-fetch on:0 init:"$CPT_FETCH" -- "Do not refresh the repositories" + flag CPT_PROMPT -y --no-prompt on:0 init:"$CPT_PROMPT" -- "Do not prompt for confirmation" + param CPT_ROOT --root init:"$CPT_ROOT" -- "Use an alternate root directory" + disp :usage -h --help -- "Show this help message" + disp :version -v --version -- "Print version information" } eval "$(getoptions parser_definition parse "$0")" -- cgit v1.2.3