I believe in illumos, getopt_long() without any long options will operate
similar to glibc’s getopt() in that it will permute argv to find and process
options intermixed with arguments (however as the way that glibc does this is
not documented, when there are ambiguities on if a particular entry in argv is
an argument or option, you may still have diverging results — this is also a
potential issue on the BSDs as well — I have a strong suspicion the
getopt_long() implementation on illumos came from NetBSD).
You can also add a + to the beginning of the option string to force options to
appear first (or rather to stop option processing at the first non-option IIRC)
and should have the same effect as setting POSIXLY_CORRECT. It should also
prevent any potential ambiguities in processing the cmdline input (I believe
the zfs subcommands don’t have any potential ambiguities today, but that
doesn’t mean that will always be the case if the mixing of options and
arguments is allowed). IIRC using + works on Linux, the BSDs, and illumos, so
I don’t think there’d be any portability concerns (though since it is somewhat
stricter, if adopted, I would of course double check that cmdlines get
processed as expected).
From: Brian Behlendorf
Reply: openzfs-developer
Date: September 25, 2018 at 1:32:51 PM
To: openzfs/openzfs
Cc: Subscribed
Subject: [developer] Re: [openzfs/openzfs] 9466 add JSON output support to
channel programs (#619)
I've bumped on this a few times now. This getopt(3) behavior is controlled by
the POSIXLY_CORRECT environment variable. Setting this will get you the illumos
behavior, but it is not the default on Linux. See the full discussion in the
man page.
http://man7.org/linux/man-pages/man3/getopt.3.html
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
openzfs / openzfs-developer / see discussions + participants + delivery options
Permalink
signature.asc
Description: Message signed with OpenPGP using AMPGpg
smime.p7s
Description: S/MIME cryptographic signature
This is a multi-part message in MIME format...
=_1537974549-523073-457--