From a7ee16d4543496548058198b56593559e5a17314 Mon Sep 17 00:00:00 2001 From: Patrick Van der Veken Date: Sat, 9 Jan 2021 14:22:24 +0100 Subject: [PATCH] Fixed problem with old AWK's max input line of 3000 bytes --- manage_sudo.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/manage_sudo.sh b/manage_sudo.sh index 1e9fce5..79579f6 100644 --- a/manage_sudo.sh +++ b/manage_sudo.sh @@ -42,7 +42,7 @@ # or LOCAL_CONFIG_FILE instead # define the version (YYYY-MM-DD) -typeset -r SCRIPT_VERSION="2020-12-30" +typeset -r SCRIPT_VERSION="2021-01-09" # name of the global configuration file (script) typeset -r GLOBAL_CONFIG_FILE="manage_sudo.conf" # name of the local configuration file (script) @@ -512,10 +512,17 @@ typeset CHECK_LINE="$1" typeset CHECK_DELIM="$2" typeset NUM_FIELDS=0 -NUM_FIELDS=$(print "${CHECK_LINE}" | awk -F "${CHECK_DELIM}" '{ print NF }' 2>/dev/null) +case "${OS_NAME}" in + HP-UX) + # wark around old awk's limit on input of max 3000 bytes + NUM_FIELDS=$(print "${CHECK_LINE}" | tr "${CHECK_DELIM}" '\n' 2>/dev/null | wc -l 2>/dev/null) + ;; + *) + NUM_FIELDS=$(print "${CHECK_LINE}" | awk -F "${CHECK_DELIM}" '{ print NF }' 2>/dev/null) + ;; +esac -# shellcheck disable=SC2086 -print ${NUM_FIELDS} +print "${NUM_FIELDS}" return 0 }