Quantcast
Channel: getopt, getopts or manual parsing - what to use when I want to support both short and long options? - Unix & Linux Stack Exchange
Browsing all 6 articles
Browse latest View live

Answer by bubla for getopt, getopts or manual parsing - what to use when I...

Every discussion on this matter highlight the option to write the parsing code manually - only then you can be sure about the functionality and portability. I advise you not to write code that you can...

View Article



Answer by Potherca for getopt, getopts or manual parsing - what to use when I...

You could use getopt on systems that support it and use a fall back for systems that don't.For instance pure-getopt is implemented in pure Bash to be a drop-in replacement for GNU getopt.

View Article

Answer by vonbrand for getopt, getopts or manual parsing - what to use when I...

If it has to be portable to a range of Unices, you'd have to stick to POSIX sh. And AFAIU there you just have no choice but rolling argument handling by hand.

View Article

Answer by l0b0 for getopt, getopts or manual parsing - what to use when I...

getopt vs getopts seems to be a religious issue. As for the arguments against getopt in the Bash FAQ:"getopt cannot handle empty arguments strings" seems to refer to a known issue with optional...

View Article

Answer by Stéphane Chazelas for getopt, getopts or manual parsing - what to...

There's this getopts_long written as a POSIX shell function that you may embed inside your script.Note that the Linux getopt (from util-linux) works correctly when not in traditional mode and supports...

View Article


getopt, getopts or manual parsing - what to use when I want to support both...

Currently I'm writing a Bash script which has the following requirements:it should run on a wide variety of Unix/Linux platformsit should support both short and (GNU) long optionsI know that getopts...

View Article
Browsing all 6 articles
Browse latest View live




Latest Images