[Top][All Lists]

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

Re: Handling getopt for option without optional argument value

From: Greg Wooledge
Subject: Re: Handling getopt for option without optional argument value
Date: Fri, 23 Jul 2021 14:43:40 -0400

On Fri, Jul 23, 2021 at 08:26:26PM +0200, 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.

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


for i; do
    case "$i" in
            echo >&2 "`basename $0` called with non ANSI/ISO C option $i"
            exit 1

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

reply via email to

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