xstr(1) on Solnix vs Linux and the BSDs

On Solnix, xstr is the illumos xstr at /usr/bin/xstr. It does the same job as the FreeBSD xstr: it hashes C string literals into a shared strings file and writes x.c and xs.c. The main differences are that -c takes the file name as its own argument, and that Solnix adds -l array to rename the generated array.

What Solnix runs

A default Solnix system runs the illumos xstr at /usr/bin/xstr. /usr/ucb/xstr is also shipped, but the bundle does not describe it. The package is pkgs.solnix.illumos-world-man.

Differences

Compared withTopicWhat differs
FreeBSD-c argument formOn Solnix, -c takes the source file name as its option argument: xstr -c filename. On FreeBSD, -c is a plain flag combined as [-cv], and the files are separate operands: [file ...]. A command line written for one form can break on the other.
Source: Solnix xstr(1) SYNOPSIS, OPTIONS (-c filename); FreeBSD xstr(1) SYNOPSIS, -c
FreeBSD-l array optionSolnix xstr has -l array, which names the array used in the generated references; the default is xstr. The FreeBSD page documents no -l and always describes the array as xstr.
Source: Solnix xstr(1) SYNOPSIS, OPTIONS (-l array); FreeBSD xstr(1) SYNOPSIS, DESCRIPTION
FreeBSDmultiple input filesThe FreeBSD synopsis accepts a list of files: [file ...]. The Solnix synopsis shows a single filename in each form. The Solnix page does not say that several files can be given.
Source: FreeBSD xstr(1) SYNOPSIS; Solnix xstr(1) SYNOPSIS
FreeBSDgenerated expressionSolnix documents string references rewritten as &xstr[number]. FreeBSD documents them as (&xstr[number]), with parentheses. Scripts or tests that match the generated x.c text may see a difference.
Source: Solnix xstr(1) DESCRIPTION; FreeBSD xstr(1) -c
FreeBSDreading standard inputBoth pages describe reading from standard input with an argument of `-`. FreeBSD lists `-` as its own option and shows xstr -c -. In the Solnix text the same example is written xstr -c -, but the dash characters are garbled in the bundle, so check the installed page.
Source: Solnix xstr(1) DESCRIPTION (cc -E example); FreeBSD xstr(1) OPTIONS (-), DESCRIPTION
FreeBSDsizeof and char array pitfallsThe Solnix NOTES warn that xstr replaces every string. This breaks sizeof("literal") and initialisers like char x[] = "xxx"; use strlen()+1 or static char *x. The FreeBSD page has no such warning, but the manual does not say its behaviour differs.
Source: Solnix xstr(1) NOTES; FreeBSD xstr(1) (no NOTES section)
FreeBSD-v detailSolnix -v prints a progress report showing where new or duplicate strings were found. FreeBSD says only "Verbose mode." so the output content is not specified there.
Source: Solnix xstr(1) -v; FreeBSD xstr(1) -v
Linux, OpenBSD, NetBSDno counterpart page suppliedThe bundle has no xstr page for Linux, OpenBSD or NetBSD. The manual does not say whether these systems ship xstr, so check before relying on it.
Source: Bundle header (only a FreeBSD 15.1 counterpart is listed)

Standards

  • POSIX: xstr is not a POSIX.1-2024 utility.
  • FreeBSD: HISTORY: the xstr command appeared in 3.0BSD. The page has no STANDARDS section.

Writing portable scripts

  • Do not assume xstr exists everywhere: the bundle documents only Solnix and FreeBSD. Test for it in the build system.
  • If you must support both, run xstr on preprocessed input piped through `-`, as in cc -E name.c | xstr -c -, and avoid -l, which only the Solnix page documents.

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.