From 7276d0213fd26ee68b62b84080261e29512871e9 Mon Sep 17 00:00:00 2001 From: Lyndon Brown Date: Sun, 3 May 2020 01:25:55 +0100 Subject: fix usage/help/man bugs - the definition of $PROGRAM as used in $USAGE strings defined in each script has been broken for a long time, being simply "lb" when it needs to be "lb COMMAND". - `config` changed $PROGRAM to "lb config" thus its output was correct in this regard unlike everything else, but with the switch to a more "intelligent" `Man()` function recently, it means that instead of `man lb config`, what was actually run was `man lb config config`, which displayed the manpage, then on exiting with `q`, it showed some sort of index line todo with a "config" search (no exact manpage match?), for which you had to enter `ctrl+c` to get rid of. this revises things to fix the issues, minimising change by changing $PROGRAM to "lb COMMAND", with the frontend overriding this. Gbp-Dch: Ignore --- functions/arguments.sh | 2 +- functions/common.sh | 3 ++- functions/man.sh | 14 ++------------ 3 files changed, 5 insertions(+), 14 deletions(-) (limited to 'functions') diff --git a/functions/arguments.sh b/functions/arguments.sh index 676925858..94e785f0e 100755 --- a/functions/arguments.sh +++ b/functions/arguments.sh @@ -16,7 +16,7 @@ Arguments () local ARGUMENTS local ERR=0 - ARGUMENTS="$(getopt --shell sh --name ${PROGRAM} --longoptions $LONGOPTS --options $SHORTOPTS -- "${@}")" || ERR=$? + ARGUMENTS="$(getopt --shell sh --name "${PROGRAM}" --longoptions $LONGOPTS --options $SHORTOPTS -- "${@}")" || ERR=$? if [ $ERR -eq 1 ]; then Echo_error "invalid argument(s)" diff --git a/functions/common.sh b/functions/common.sh index edfd4ef58..3dbc76b82 100755 --- a/functions/common.sh +++ b/functions/common.sh @@ -10,7 +10,8 @@ PROGRAM_NAME="live-build" -PROGRAM="lb" +FRONTEND="lb" +PROGRAM="${FRONTEND} $(basename "${0}")" VERSION="$(if [ -e ${LIVE_BUILD}/debian/changelog ]; then sed -e 's/.*(\(.*\)).*/\1/; s/^[0-9]://; q' ${LIVE_BUILD}/debian/changelog; else cat /usr/share/live/build/VERSION; fi)" LIVE_BUILD_VERSION="${VERSION}" diff --git a/functions/man.sh b/functions/man.sh index 472d20663..f14858b97 100755 --- a/functions/man.sh +++ b/functions/man.sh @@ -11,18 +11,8 @@ Man () { - local BASENAME - BASENAME=$(basename ${0}) - if command -v man >/dev/null - then - case $BASENAME in - $PROGRAM) - man ${PROGRAM} - ;; - *) - man ${PROGRAM} $(basename ${0}) - ;; - esac + if command -v man >/dev/null; then + man ${PROGRAM} else Echo_warning "man is not installed, falling back to usage output." Usage -- cgit v1.2.3