hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit f9792ff218f9ce635a47e3769b8e28910cabbdf7
parent 8e37ec3849a5bfd186b3487612a7dd9af46348a2
Author: Lennart Jablonka <humm@ljabl.com>
Date:   Sun, 25 Dec 2022 21:42:28 +0000

gen-stdlib.sh: reset OPTIND=1 before using getopts

"Assigning 1 to [OPTIND] causes getopts to process arguments from the
beginning the next time it is invoked."  (OpenBSD's ksh(1))

Without doing this, getopts does weird things.

While we're at it, identify the functions correctly in error messages.

Signed-off-by: Lennart Jablonka <humm@ljabl.com>

Diffstat:
Mscripts/gen-stdlib.sh | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/scripts/gen-stdlib.sh b/scripts/gen-stdlib.sh @@ -10,6 +10,7 @@ mod_var() { gen_srcs() { platform=any + OPTIND=1 while getopts p: name do case $name in @@ -46,6 +47,7 @@ gen_srcs() { gen_ssa() { platform=any + OPTIND=1 while getopts p: name do case $name in @@ -53,7 +55,7 @@ gen_ssa() { platform="$OPTARG" ;; ?) - printf 'Invalid use of gen_srcs' >&2 + printf 'Invalid use of gen_ssa' >&2 exit 1 ;; esac @@ -85,6 +87,7 @@ EOF gen_lib() { platform=any + OPTIND=1 while getopts p: name do case $name in @@ -92,7 +95,7 @@ gen_lib() { platform="$OPTARG" ;; ?) - printf 'Invalid use of gen_srcs' >&2 + printf 'Invalid use of gen_lib' >&2 exit 1 ;; esac