getopt(1) on Solnix vs Linux and the BSDs

On Solnix, getopt is the illumos /usr/bin/getopt, a traditional Bell-style getopt with only an optstring. It has none of the Linux util-linux extensions (long options, quoted output, -o/-l/-s). The page itself says getopts supersedes it.

What Solnix runs

A default Solnix system runs the illumos getopt at /usr/bin/getopt. No other variants are shipped. The Solnix page says the getopts command supersedes getopt, and it points to getoptcvt(1) and getopts(1) in SEE ALSO.

Differences

Compared withTopicWhat differs
Linuxoptions and long optionsSolnix getopt takes only an optstring followed by the arguments to parse. It has no -o, -l, -a, -n, -q, -Q, -s, -u, -U, -T, -h or -V. Linux getopt supports these, including long options via -l/--longoptions.
Source: Solnix getopt(1) SYNOPSIS; Linux getopt(1) OPTIONS (-a, -l, -n, -o, -q, -Q, -s, -T, -u, -U)
Linuxquoted output and whitespaceLinux getopt can emit shell-quoted output, to be used with eval, which preserves whitespace and special characters in arguments. The Solnix page documents no quoting, and says whitespace-separated, quoted option-arguments are not handled correctly.
Source: Linux getopt(1) DESCRIPTION, -s, -u; Solnix getopt(1) NOTES
Linuxcalling format and -T testLinux getopt uses the old-style format when the first parameter does not start with '-' or when GETOPT_COMPATIBLE is set. Linux -T exits 4 with no output to detect the enhanced version. The Solnix page documents only the old format and no -T.
Source: Linux getopt(1) DESCRIPTION, COMPATIBILITY, -T; Solnix getopt(1) SYNOPSIS
Linuxenvironment variablesLinux getopt reads POSIXLY_CORRECT and GETOPT_COMPATIBLE, which change parsing and output. The Solnix page documents no environment variables.
Source: Linux getopt(1) ENVIRONMENT, COMPATIBILITY; Solnix getopt(1) (no ENVIRONMENT section)
Linuxparameter shufflingLinux getopt in compatibility mode still shuffles, outputting non-option parameters at the end, unless POSIXLY_CORRECT is set. The Solnix page says only that options are split out, with '--' placed at the end of the options.
Source: Linux getopt(1) COMPATIBILITY; Solnix getopt(1) DESCRIPTION
OpenBSDoptional arguments (::)OpenBSD getopt accepts a letter followed by two colons for an optional argument that cannot be separated by whitespace, and calls this a non-POSIX extension. The Solnix page documents only a single colon.
Source: OpenBSD getopt(1) DESCRIPTION; Solnix getopt(1) DESCRIPTION
FreeBSD, OpenBSDexit status and set idiomFreeBSD documents that getopt exits >0 on an option letter not in optstring, and its SYNOPSIS captures $? before set. OpenBSD warns that set -- `getopt ...` hides getopt's exit status. The Solnix page shows exactly that set -- form and documents no exit status.
Source: FreeBSD getopt(1) SYNOPSIS, EXIT STATUS; OpenBSD getopt(1) CAVEATS; Solnix getopt(1) SYNOPSIS
FreeBSD, OpenBSD, NetBSDSolnix-only option parsing noteIf an option taking an argument is followed by a value equal to a letter in optstring (cmd -o -a filename), Solnix getopt always treats it as the option-argument of -o. The BSD pages do not describe this case.
Source: Solnix getopt(1) NOTES; FreeBSD/OpenBSD/NetBSD getopt(1) BUGS
OpenBSD, NetBSDdeprecation wordingOpenBSD says getopt cannot handle option arguments containing whitespace and recommends getopts. NetBSD says getopt should not be used in new scripts. Solnix says getopts supersedes getopt. FreeBSD gives no such recommendation in the text.
Source: OpenBSD getopt(1) DESCRIPTION; NetBSD getopt(1) DESCRIPTION; Solnix getopt(1) DESCRIPTION; FreeBSD getopt(1)

Standards

  • POSIX: getopt is not a POSIX.1-2024 utility.
  • Solnix: ATTRIBUTES: CSI is enabled.
  • FreeBSD: HISTORY: written by Henry Spencer from a Bell Labs manual page; behavior believed identical to the Bell version.
  • OpenBSD: HISTORY: written by Henry Spencer from a Bell Labs manual page; behavior believed identical to the Bell version.
  • NetBSD: HISTORY: written by Henry Spencer from a Bell Labs manual page; behavior believed identical to the Bell version.

Writing portable scripts

  • Prefer the getopts shell builtin: the Solnix, OpenBSD and NetBSD pages all point to it, and it avoids getopt's whitespace problems.
  • If you must use getopt, call it only in the old form (getopt optstring args) and never rely on -o, -l or -T, which exist only in Linux util-linux getopt.

Every difference here is taken from the manual pages linked above: Solnix's published page, Linux (man-pages and the GNU and util-linux manuals), FreeBSD, OpenBSD and NetBSD. Each row names its source. Where a manual is silent, this page is too. Compiled 2026-10-26. Found a mistake? Mail hackers@lists.solnix.io.