From 4ee9059f956c2a5d55aa36f6f9354b135455abbf Mon Sep 17 00:00:00 2001 From: oddlama Date: Mon, 6 Dec 2021 13:34:27 +0100 Subject: [PATCH] chore: more accurate check for ncurses availability --- configure | 2 +- scripts/utils.sh | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/configure b/configure index f99665f..ccd8e44 100755 --- a/configure +++ b/configure @@ -44,7 +44,7 @@ while [[ $# -gt 0 ]]; do shift done -check_has_programs dialog ncurses +check_has_programs dialog ncurses=ncursesw6-config # Wrap dialog in two functions to prevent it from cluttering stderr. function dialog_wrapper() { dialog_out=$(command dialog --colors "$@" 3>&2 2>&1 1>&3 3>&-); } diff --git a/scripts/utils.sh b/scripts/utils.sh index 80d601f..5d5447a 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -331,10 +331,22 @@ function parse_arguments() { function check_has_programs() { local failed=() + local tuple local program - for program in "$@"; do - type "$program" &>/dev/null \ - || failed+=("$program") + local checkfile + for tuple in "$@"; do + program="${tuple%%=*}" + checkfile="${tuple##*=}" + if [[ -z "$checkfile" ]]; then + type "$program" &>/dev/null \ + || failed+=("$program") + elif [[ "${checkfile:0:1}" == "/" ]] + [[ -e "$checkfile" ]] \ + || failed+=("$program") + else + type "$checkfile" &>/dev/null \ + || failed+=("$program") + fi done [[ "${#failed[@]}" -eq 0 ]] \