help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Bash script supporting complex options like GNU find


From: Greg Wooledge
Subject: Re: [Help-bash] Bash script supporting complex options like GNU find
Date: Mon, 12 Feb 2018 09:52:30 -0500
User-agent: NeoMutt/20170113 (1.7.2)

On Mon, Feb 12, 2018 at 08:46:39AM -0600, Peng Yu wrote:
> > https://mywiki.wooledge.org/BashFAQ/035
> 
> The examples there cannot be readily extended to support '(' ')' '-a'
> '-o' '!' as in GNU find. In fact, I doubt that getopt can support
> them.
> 
> If you think otherwise, could you show an example how '(' ')' '-a'
> '-o' '!' can be supported with getopt?

getopt(1) does not "support" anything.  All it does is rewite combined
options like -abc as -a -b -c so that a simple while loop can more easily
parse them.

You will have to write your own syntax parsing for this.

getopt(1) is a really bad idea, and you should not be using it, regardless
of whether you also need to write an infix expression parser.



reply via email to

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