basename(1) on Solnix vs Linux and the BSDs

On Solnix, basename is the illumos /usr/bin/basename, which takes one string and an optional suffix. It has no -a, -s or -z. Unlike Linux and FreeBSD, it cannot process several names in one call. In /usr/bin the suffix is an expr(1) pattern, not a literal string.

What Solnix runs

A default Solnix system runs the illumos /usr/bin/basename. /usr/xpg4/bin/basename and /usr/ucb/basename are also shipped. The page documents one difference: in /usr/bin the suffix is a pattern as defined on expr(1), while in /usr/xpg4/bin it is a plain string with no special characters. The bundle does not describe /usr/ucb/basename. The Solnix page also covers dirname, which takes one string.

Differences

Compared withTopicWhat differs
Linux, FreeBSDmultiple names (-a)Solnix basename takes one string and an optional suffix, with no -a. Linux and FreeBSD accept -a to treat every argument as a name. A script using basename -a fails or misbehaves on Solnix.
Source: Solnix basename(1) SYNOPSIS; Linux basename(1) -a, --multiple; FreeBSD basename(1) SYNOPSIS, -a
Linux, FreeBSD-s suffix optionSolnix has no -s. The suffix is only the optional second operand. Linux and FreeBSD accept -s suffix, and on Linux it implies -a. Linux -s takes the suffix and treats all other arguments as names.
Source: Solnix basename(1) SYNOPSIS; Linux basename(1) -s, --suffix; FreeBSD basename(1) DESCRIPTION (-s)
Linux-z NUL outputSolnix basename has no -z to end output with NUL. Linux -z does that. The Solnix page documents no way to change the output terminator.
Source: Linux basename(1) -z, --zero; Solnix basename(1) SYNOPSIS
all foursuffix is a pattern in /usr/binIn Solnix /usr/bin/basename the suffix is a pattern defined on expr(1). In /usr/xpg4/bin/basename it is a plain string. The Linux, FreeBSD, OpenBSD and NetBSD pages describe the suffix as a literal trailing string and mention no pattern syntax.
Source: Solnix basename(1) DESCRIPTION (/usr/bin, /usr/xpg4/bin); Linux basename(1) DESCRIPTION; FreeBSD, OpenBSD, NetBSD basename(1) DESCRIPTION
FreeBSDsuffix equal to whole nameFreeBSD does not strip a suffix that is identical to the remaining characters of string. The Solnix page does not say what happens in that case.
Source: FreeBSD basename(1) DESCRIPTION; Solnix basename(1) DESCRIPTION
FreeBSDtrailing slashesFreeBSD basename and dirname first strip trailing slashes. The Solnix page says only that any prefix ending in / is deleted, and does not describe trailing slashes.
Source: FreeBSD basename(1) DESCRIPTION; Solnix basename(1) DESCRIPTION
FreeBSDdirname with several argumentsFreeBSD dirname accepts several strings (dirname string [...]). Solnix and NetBSD dirname take one string.
Source: FreeBSD basename(1) SYNOPSIS; Solnix basename(1) SYNOPSIS; NetBSD basename(1) SYNOPSIS
Linux, OpenBSDdirname documentationSolnix, FreeBSD and NetBSD document dirname on the basename page. The Linux and OpenBSD basename pages do not, and refer to dirname(1) in SEE ALSO.
Source: Linux basename(1) SEE ALSO; OpenBSD basename(1) SEE ALSO; Solnix basename(1) NAME
all fourenvironment variablesThe Solnix page lists LANG, LC_ALL, LC_CTYPE, LC_MESSAGES and NLSPATH as affecting basename and dirname. The Linux, FreeBSD, OpenBSD and NetBSD pages in the bundle list no environment variables.
Source: Solnix basename(1) ENVIRONMENT VARIABLES; Linux, FreeBSD, OpenBSD, NetBSD basename(1)

Standards

  • POSIX: basename is a POSIX.1-2024 utility.
  • FreeBSD: basename and dirname are expected to be IEEE Std 1003.2 (“POSIX.2”) compatible.
  • OpenBSD: The basename utility is compliant with the specification (the page does not name the standard).
  • NetBSD: basename and dirname conform to IEEE Std 1003.2-1992 (“POSIX.2”).
  • Solnix: The page's SEE ALSO lists standards(7) and attributes(7), but the bundle text has no ATTRIBUTES or STANDARDS section.

Writing portable scripts

  • Call basename with exactly one name and an optional suffix, with no options. Loop in the shell for several names instead of using -a or -s.
  • Do not rely on how the suffix is interpreted. /usr/bin/basename on Solnix treats it as an expr(1) pattern, so avoid regular-expression characters in it, or strip the suffix with shell parameter expansion.

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.