help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Handling getopt for option without optional argument value


From: lisa-asket
Subject: Handling getopt for option without optional argument value
Date: Fri, 23 Jul 2021 21:24:32 +0200 (CEST)

From: Greg Wooledge <greg@wooledge.org>
To: help-bash@gnu.org
Subject: Re: Handling getopt for option without optional argument value
Date: 23/07/2021 20:43:40 Europe/Paris

On Fri, Jul 23, 2021 at 08:26:26PM +0200, lisa-asket@perso.be wrote:
> Could not the people at gcc help a little bit?

GCC and its utilities use the -findopts option style. This extends
even to their wrapper scripts, like "c89", which was actually one of
the first GNU shell programs that I found. I didn't include it in my
previous message because it doesn't have what I would consider to be
"nontrivial option parsing".

The "-xyz to -x -y -z" unrolling that getopt does is fundamentally
incompatible with the -findopts option style. There's no way to tell
whether -bar is meant to be one option, or three options. So, it wouldn't
make sense for GCC's scripts to use getopt or getopts.



---

I find that using "-x -y -z" rather than "-xyz" is of minor problem compared to 
not

being have the capability to use long options.

---





Here is the entire /usr/bin/c89 script from my Debian installation:

#! /bin/sh

# Call the appropriate C compiler with options to accept ANSI/ISO C
# The following options are the same (as of gcc-2.95):
# -ansi
# -std=c89
# -std=iso9899:1990

extra_flag=-std=c89

for i; do
case "$i" in
-ansi|-std=c89|-std=iso9899:1990)
extra_flag=
;;
-std=*)
echo >&2 "`basename $0` called with non ANSI/ISO C option $i"
exit 1
;;
esac
done

exec gcc $extra_flag ${1+"$@"}






reply via email to

[Prev in Thread] Current Thread [Next in Thread]