help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Allow getopts to do what is capable with getopt?


From: Peng Yu
Subject: Re: [Help-bash] Allow getopts to do what is capable with getopt?
Date: Thu, 26 Mar 2015 09:45:45 -0500

On Thu, Mar 26, 2015 at 9:44 AM, Chet Ramey <address@hidden> wrote:
> On 3/25/15 5:55 PM, Bob Proulx wrote:
>
>> AFAIK it was introduced into AT&T ksh way back before 1986.  I didn't
>> research this.  But that is where my memory recalls it without fact
>> checking.  But at the time back in the 1980's many things were added
>> as builtins to ksh.  Note that at the time it was added to ksh the
>> Unix getopt was not as featureful as the current one.  Comparing the
>> same era getopt to the same era getopts and they are much more
>> comparable.  Bash is as compatible as practical to other shells.
>> Therefore it is in Bash for compatibility.
>
> `getopts' was first introduced in the SVR3 sh, and ksh-88 adopted it from
> there.
>
>
>>> And using getopt in a script is atrociously stupid UNLESS you have TESTED
>>> that the getopt you are invoking is in fact the non-standard Linux one.
>>
>> I think that is too harsh.  It is perfectly reasonable to use getopt
>> in portable shell scripts.  I have great respect for your deep
>> knowledge of the shell but I disagree that getopt should never be used
>> in shell scripts.
>
> I think Greg was saying that if the only reason to use getopt in favor of
> getopts is the features that the util-linux version offers, then you had
> better be sure that's the one you're getting.

I am sure.

> If you're not going to use
> any of those features you should just go ahead and use getopts.
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



-- 
Regards,
Peng



reply via email to

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