fix getopt behavior

This commit is contained in:
fatalerrors
2026-03-10 11:40:37 +01:00
parent 02a1e25df2
commit 0a4206b890
2 changed files with 68 additions and 59 deletions

View File

@@ -45,6 +45,7 @@ ver()
return 1 return 1
fi fi
eval set -- "$PARSED" eval set -- "$PARSED"
while true; do
case "$1" in case "$1" in
-h|--help) -h|--help)
printf "ver: Display the current profile version.\nUsage: ver\n" printf "ver: Display the current profile version.\nUsage: ver\n"
@@ -59,6 +60,7 @@ ver()
return 1 return 1
;; ;;
esac esac
done
[[ -z $PROFVERSION ]] && \ [[ -z $PROFVERSION ]] && \
disp W "No version defined. Profile is probably badly installed." && \ disp W "No version defined. Profile is probably badly installed." && \
@@ -80,6 +82,7 @@ meteo()
return 1 return 1
fi fi
eval set -- "$PARSED" eval set -- "$PARSED"
while true; do
case "$1" in case "$1" in
-h|--help) -h|--help)
printf "meteo: Fetch weather data.\nUsage: meteo [city1 city2 ...]\n" printf "meteo: Fetch weather data.\nUsage: meteo [city1 city2 ...]\n"
@@ -94,6 +97,7 @@ meteo()
return 1 return 1
;; ;;
esac esac
done
local cities=("$@") local cities=("$@")
[[ $# -eq 0 ]] && cities=("$DEFAULT_CITY") [[ $# -eq 0 ]] && cities=("$DEFAULT_CITY")
@@ -119,6 +123,7 @@ showinfo()
return 1 return 1
fi fi
eval set -- "$PARSED" eval set -- "$PARSED"
while true; do
case "$1" in case "$1" in
-h|--help) -h|--help)
printf "showinfo: Display system information (hostname, kernel, uptime).\nUsage: showinfo\n" printf "showinfo: Display system information (hostname, kernel, uptime).\nUsage: showinfo\n"
@@ -133,6 +138,8 @@ showinfo()
return 1 return 1
;; ;;
esac esac
done
printf "\n" printf "\n"
if command -v figlet >/dev/null 2>&1; then if command -v figlet >/dev/null 2>&1; then
if [[ -s /usr/share/figlet/ansi_shadow.flf ]]; then if [[ -s /usr/share/figlet/ansi_shadow.flf ]]; then

View File

@@ -56,7 +56,7 @@ setlocale()
return 1 return 1
fi fi
eval set -- "$PARSED" eval set -- "$PARSED"
while true; do
case "$1" in case "$1" in
-h|--help) -h|--help)
printf "setlocale: Configure system environment locale variables.\n\n" printf "setlocale: Configure system environment locale variables.\n\n"
@@ -74,6 +74,8 @@ setlocale()
return 1 return 1
;; ;;
esac esac
done
local loc=$1 local loc=$1
[[ -z $loc ]] && disp E "No locale specified." && return 1 [[ -z $loc ]] && disp E "No locale specified." && return 1