dirname(1) on Solnix vs Linux and the BSDs
The dirname on PATH in a default Solnix system is the illumos /usr/bin/dirname, which takes one string and has no options. The published Solnix page describes GNU coreutils dirname (pkgs.solnix.coreutils), which adds -z/--zero and accepts several NAMEs. Scripts that rely on those GNU features fail on the default command.
The manual pages
- Solnix: dirname(1) from
pkgs.solnix.coreutils - Linux: dirname(1) coreutils-full-9.11
- FreeBSD: dirname(1) 15.1-RELEASE
- OpenBSD: dirname(1) 8.0
- NetBSD: dirname(1) 11.0
- Standard: POSIX.1-2024 (IEEE Std 1003.1-2024),
dirname
What Solnix runs
The published page is GNU coreutils 9.7 dirname from pkgs.solnix.coreutils, but /usr/bin/dirname is the illumos one. The illumos page documents the synopsis 'dirname string' and no options. No other illumos variants of dirname are shipped (/usr/xpg4/bin exists only for basename). To get -z/--zero and multiple NAME arguments, install pkgs.solnix.coreutils. The bundle does not say how its dirname is named or placed on PATH.
Differences
| Compared with | Topic | What differs |
|---|---|---|
| Linux | same program as the published page | The published Solnix page (GNU coreutils dirname) and the Linux page have the same synopsis, -z/--zero, --help and --version. The default Solnix /usr/bin/dirname is not that program. Only after installing pkgs.solnix.coreutils does Solnix match Linux.Source: Solnix dirname(1) SYNOPSIS, OPTIONS; Linux dirname(1) SYNOPSIS, OPTIONS; illumos dirname(1) SYNOPSIS |
| Linux | -z / --zero | GNU dirname -z ends each output line with NUL instead of newline. The illumos dirname on PATH documents no options, so -z is not documented there.Source: Solnix dirname(1) -z, --zero; Linux dirname(1) -z, --zero; illumos dirname(1) SYNOPSIS |
| Linux | --help and --version | GNU dirname has --help and --version. The illumos dirname page lists neither option.Source: Solnix dirname(1) --help, --version; Linux dirname(1) --help, --version; illumos dirname(1) SYNOPSIS |
| Linux | multiple arguments | GNU dirname takes NAME... and prints a result for each. The illumos synopsis shows one string. The illumos page does not say what happens with extra arguments, so do not rely on them on the default command. Source: Solnix dirname(1) SYNOPSIS; Linux dirname(1) SYNOPSIS; illumos dirname(1) SYNOPSIS |
| FreeBSD | multiple arguments | FreeBSD dirname takes 'string [...]', so several paths are allowed. The illumos synopsis shows a single string. Source: FreeBSD dirname(1) SYNOPSIS; illumos dirname(1) SYNOPSIS |
| OpenBSD, NetBSD | single argument | OpenBSD and NetBSD dirname take a single pathname or string, as the illumos one does. GNU dirname (published Solnix page and Linux) accepts NAME.... Source: OpenBSD dirname(1) SYNOPSIS; NetBSD dirname(1) SYNOPSIS; Linux dirname(1) SYNOPSIS |
| FreeBSD, OpenBSD, NetBSD | no -z or long options | The FreeBSD, OpenBSD and NetBSD dirname pages document no -z, --zero, --help or --version. The only dirname-related FreeBSD options, -a and -s, belong to basename.Source: FreeBSD dirname(1) SYNOPSIS; OpenBSD dirname(1) SYNOPSIS; NetBSD dirname(1) SYNOPSIS |
| all four | empty or no-slash input | The GNU page says a NAME with no / gives '.'. The illumos, FreeBSD, OpenBSD and NetBSD dirname pages do not state results for no-slash input, trailing slashes or empty strings. Test those edge cases rather than assume. Source: Solnix dirname(1) DESCRIPTION; illumos dirname(1) DESCRIPTION; FreeBSD dirname(1) DESCRIPTION; OpenBSD dirname(1) DESCRIPTION; NetBSD dirname(1) DESCRIPTION |
| all four | exit status | The illumos, FreeBSD, OpenBSD and NetBSD pages document exit 0 on success and >0 on error. The GNU dirname page documents no EXIT STATUS section. Source: illumos dirname(1) EXIT STATUS; FreeBSD dirname(1) EXIT STATUS; OpenBSD dirname(1) EXIT STATUS; NetBSD dirname(1) EXIT STATUS; Linux dirname(1) |
| all four | environment variables | The illumos page lists LANG, LC_ALL, LC_CTYPE, LC_MESSAGES and NLSPATH as affecting dirname. The Linux and BSD dirname pages have no ENVIRONMENT section. Source: illumos dirname(1) ENVIRONMENT VARIABLES; Linux, FreeBSD, OpenBSD and NetBSD dirname(1) |
Standards
- POSIX: dirname is a POSIX.1-2024 utility.
- Solnix: The illumos page refers to standards(7) and attributes(7), but the bundle text shows no further standards statement for dirname.
- FreeBSD: The basename and dirname utilities are expected to be IEEE Std 1003.2 (“POSIX.2”) compatible.
- OpenBSD: The dirname utility is compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) specification.
- NetBSD: The basename and dirname utilities conform to IEEE Std 1003.2-1992 (“POSIX.2”).
Writing portable scripts
- Call dirname with exactly one argument and no options, for example dirname "$path". Use a loop for several paths. This works with the illumos, GNU and BSD versions.
- Do not rely on
-z/--zero,--helpor--versionin portable scripts. They are GNU-only and missing from the default Solnix command.
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.