test(1) on Solnix vs Linux and the BSDs

On Solnix, test and [ are the illumos /usr/bin/test, and the shells sh, csh, ksh and ksh93 each have a built-in version. Its numeric operators accept floating-point values, and some primaries are unavailable in sh or behave differently in csh. -a and -o are unary tests here, not the Linux/BSD binary and/or operators.

What Solnix runs

A default Solnix system runs the illumos /usr/bin/test. /usr/xpg4/bin/test and /usr/ucb/test are also shipped, but the bundle does not describe how they differ. The synopsis lists built-in versions in sh, csh, ksh and ksh93, and the page says some primaries are not available in sh or csh. Check which version your shell runs.

Differences

Compared withTopicWhat differs
all four-a and -oThe Solnix page lists -a file as a unary 'file exists' test and -o option as a unary 'shell option is on' test. Linux, FreeBSD, OpenBSD and NetBSD document -a and -o as binary AND and OR operators.
Source: Solnix test(1) OPERANDS -a, -o; Linux test(1) EXPRESSION1 -a/-o; FreeBSD/OpenBSD/NetBSD test(1) -a, -o
all fournumeric comparisonSolnix -eq, -ne, -gt, -ge and -lt accept integers, floating-point numbers and constants such as Inf and NaN, in any format C99/XPG6/SUS specifies. The Linux and BSD pages describe integers only.
Source: Solnix test(1) OPERANDS n1 -eq n2; Linux test(1) INTEGER1 -eq INTEGER2; FreeBSD/OpenBSD/NetBSD test(1) n1 -eq n2
all four-t default descriptorSolnix -t with no argument tests file descriptor 1. The Linux and BSD pages show -t with a required descriptor and state no default.
Source: Solnix test(1) -t [file_descriptor]; Linux test(1) -t FD; FreeBSD/OpenBSD/NetBSD test(1) -t file_descriptor
all four-f and PATH with /usr/ucbIf /usr/bin/sh users put /usr/ucb before /usr/bin in PATH, Solnix -f is true for any existing non-directory. The csh built-in always behaves this way. The Linux and BSD pages describe -f only as 'regular file'.
Source: Solnix test(1) OPERANDS -f; Linux/FreeBSD/OpenBSD/NetBSD test(1) -f
all fourprimaries not available in shSolnix marks -a file, -e, -G, -O, -S, -nt, -ot and -ef as not available in sh, and -o as not available in csh or sh. The Linux and BSD pages make no such per-shell restriction.
Source: Solnix test(1) OPERANDS -e, -G, -O, -S, -nt, -ot, -ef, -o; Linux/BSD test(1) primaries
all fourno argumentsSolnix test with no arguments sets a non-zero exit status. Linux calls an omitted expression false. FreeBSD, OpenBSD and NetBSD return 1.
Source: Solnix test(1) DESCRIPTION; Linux test(1) DESCRIPTION; FreeBSD/OpenBSD/NetBSD test(1) DESCRIPTION
FreeBSD, OpenBSD, NetBSDexit status for errorsFreeBSD, OpenBSD and NetBSD document exit status >1 for an error. The Solnix page says 0 is true and 1 is false, and gives no separate error status.
Source: Solnix test(1) DESCRIPTION; FreeBSD/OpenBSD/NetBSD test(1) EXIT STATUS
LinuxLinux-only primaries and --helpLinux documents -N, -l STRING and the string operators > and < (current locale). The visible Solnix text lists none of them. The Linux [ honors --help and --version, but test treats them as strings.
Source: Linux test(1) -N, INTEGER, STRING1 > STRING2, --help; Solnix test(1) OPERANDS
FreeBSD, OpenBSD, NetBSDstring < and > and ==FreeBSD, OpenBSD and NetBSD document s1 < s2 and s1 > s2 (binary or ASCII value order). FreeBSD also accepts == for =. The visible Solnix text lists only = and !=.
Source: FreeBSD test(1) s1 < s2, COMPATIBILITY; OpenBSD/NetBSD test(1) s1 < s2; Solnix test(1) OPERANDS
FreeBSD, NetBSD-h versus -L preferenceFreeBSD says -h is retained for compatibility and to use -L. NetBSD says the opposite: -L is retained and -h is preferred. Solnix, Linux and OpenBSD list -h and -L as the same test.
Source: FreeBSD test(1) -h; NetBSD test(1) -L; Solnix test(1) -h, -L; Linux test(1) -h; OpenBSD test(1) -h, -L
Linux, FreeBSD, NetBSDambiguity of -a, -o and parenthesesLinux calls binary -a and -o ambiguous. NetBSD advises against more than 4 operands and against -a, -o and parentheses. FreeBSD says both sides of -a and -o are always evaluated. Chain separate test calls with && or || instead.
Source: Linux test(1) 'Binary -a and -o are ambiguous'; NetBSD test(1) CAVEATS; FreeBSD test(1) BUGS
all fourowner permission bitsSolnix says -r, -w or -x on a file you own is false if the owner bit is not set, even when the group or other bit is set. The other pages do not describe this.
Source: Solnix test(1) OPERANDS; Linux/BSD test(1) -r, -w, -x

Standards

  • POSIX: test is a POSIX.1-2024 utility.
  • Solnix: The page refers to largefile(7) for files of 2 Gbyte or more, and numbers follow formats specified by C99/XPG6/SUS.
  • FreeBSD: test implements a superset of IEEE Std 1003.2 (“POSIX.2”). The primaries <, ==, >, -ef, -nt, -ot, -G and -O are extensions.
  • OpenBSD: test is compliant with IEEE Std 1003.1-2008 (“POSIX.1”). The primaries -G, -k, -O, -nt, -ot, -ef, < and > are extensions. The operators -a, -o and () are marked as XSI and obsolete.
  • NetBSD: test implements a superset of IEEE Std 1003.2 (“POSIX.2”).

Writing portable scripts

  • Avoid -a, -o and parentheses: chain [ ... ] && [ ... ] or [ ... ] || [ ... ] instead. On Solnix, -a and -o with a single operand mean something different.
  • Use only integer operands with -eq, -ne, -gt, -ge, -lt and -le, and avoid -e, -G, -O, -S, -nt, -ot and -ef if the script must run under Solnix /bin/sh. Use -L or -h consistently for symbolic links.

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.