From 4d5fe341c7d5daf8006fb58aad23cb9f579f3e88 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 22 Apr 2025 18:54:14 +0100 Subject: [PATCH] ocaml-link.sh.in: Remove redundant use of getopt Also allow --cclib as an alternative, and improved error reporting when parsing the parameters to the script. Fixes: https://github.com/libguestfs/guestfs-tools/issues/16 Reported-by: Mohamed Akram --- ocaml-link.sh.in | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ocaml-link.sh.in b/ocaml-link.sh.in index f10662eb4..7ffe54170 100755 --- a/ocaml-link.sh.in +++ b/ocaml-link.sh.in @@ -28,18 +28,16 @@ # Pass the cclib argument separately, and the rest as separated # arguments. -TEMP=`getopt -a -o '' --long 'cclib:' \ - -n "$(basename $0)" -- "$@"` -if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi -eval set -- "$TEMP" - cclib= while true ; do case "$1" in -cclib|--cclib) cclib="$2" ; shift 2 ;; + -cclib=*|--cclib=*) cclib="${1#*=}"; shift 1 ;; --) shift ; break ;; - *) echo "Internal error!" ; exit 1 ;; + *) + printf >&2 "usage: %s [-cclib lib] -- arg ...\n" "$(basename "$0")" + exit 2 ;; esac done