From 0a4206b89012112173e01fb31dbfcd9d89751c5d Mon Sep 17 00:00:00 2001 From: fatalerrors Date: Tue, 10 Mar 2026 11:40:37 +0100 Subject: [PATCH] fix getopt behavior --- profile.d/info.sh | 91 +++++++++++++++++++++++++---------------------- profile.d/lang.sh | 36 ++++++++++--------- 2 files changed, 68 insertions(+), 59 deletions(-) diff --git a/profile.d/info.sh b/profile.d/info.sh index 68a8440..0a887c7 100644 --- a/profile.d/info.sh +++ b/profile.d/info.sh @@ -45,20 +45,22 @@ ver() return 1 fi eval set -- "$PARSED" - case "$1" in - -h|--help) - printf "ver: Display the current profile version.\nUsage: ver\n" - return 0 - ;; - --) - shift - break - ;; - *) - disp E "Invalid options, use \"ver --help\" to display usage." - return 1 - ;; - esac + while true; do + case "$1" in + -h|--help) + printf "ver: Display the current profile version.\nUsage: ver\n" + return 0 + ;; + --) + shift + break + ;; + *) + disp E "Invalid options, use \"ver --help\" to display usage." + return 1 + ;; + esac + done [[ -z $PROFVERSION ]] && \ disp W "No version defined. Profile is probably badly installed." && \ @@ -80,20 +82,22 @@ meteo() return 1 fi eval set -- "$PARSED" - case "$1" in - -h|--help) - printf "meteo: Fetch weather data.\nUsage: meteo [city1 city2 ...]\n" - return 0 - ;; - --) - shift - break - ;; - *) - disp E "Invalid options, use \"meteo --help\" to display usage." - return 1 - ;; - esac + while true; do + case "$1" in + -h|--help) + printf "meteo: Fetch weather data.\nUsage: meteo [city1 city2 ...]\n" + return 0 + ;; + --) + shift + break + ;; + *) + disp E "Invalid options, use \"meteo --help\" to display usage." + return 1 + ;; + esac + done local cities=("$@") [[ $# -eq 0 ]] && cities=("$DEFAULT_CITY") @@ -119,20 +123,23 @@ showinfo() return 1 fi eval set -- "$PARSED" - case "$1" in - -h|--help) - printf "showinfo: Display system information (hostname, kernel, uptime).\nUsage: showinfo\n" - return 0 - ;; - --) - shift - break - ;; - *) - disp E "Invalid options, use \"showinfo --help\" to display usage." - return 1 - ;; - esac + while true; do + case "$1" in + -h|--help) + printf "showinfo: Display system information (hostname, kernel, uptime).\nUsage: showinfo\n" + return 0 + ;; + --) + shift + break + ;; + *) + disp E "Invalid options, use \"showinfo --help\" to display usage." + return 1 + ;; + esac + done + printf "\n" if command -v figlet >/dev/null 2>&1; then if [[ -s /usr/share/figlet/ansi_shadow.flf ]]; then diff --git a/profile.d/lang.sh b/profile.d/lang.sh index 6278408..6744f5e 100644 --- a/profile.d/lang.sh +++ b/profile.d/lang.sh @@ -56,24 +56,26 @@ setlocale() return 1 fi eval set -- "$PARSED" + while true; do + case "$1" in + -h|--help) + printf "setlocale: Configure system environment locale variables.\n\n" + printf "Usage: setlocale \n\n" + printf "Options:\n" + printf " -h, --help Display this help screen\n" + return 0 + ;; + --) + shift + break + ;; + *) + disp E "Invalid options, use \"setlocale --help\" to display usage." + return 1 + ;; + esac + done - case "$1" in - -h|--help) - printf "setlocale: Configure system environment locale variables.\n\n" - printf "Usage: setlocale \n\n" - printf "Options:\n" - printf " -h, --help Display this help screen\n" - return 0 - ;; - --) - shift - break - ;; - *) - disp E "Invalid options, use \"setlocale --help\" to display usage." - return 1 - ;; - esac local loc=$1 [[ -z $loc ]] && disp E "No locale specified." && return 1