lex(1) on Solnix vs Linux and the BSDs

On Solnix, lex is the illumos lex at /usr/bin/lex, a separate implementation. On FreeBSD, lex is flex. The option sets differ. -w and -e mean EUC support on Solnix, but -w means 'suppress warnings' on FreeBSD, and Solnix has none of flex's long options or -s, -i, -l, -P, -o and -S.

What Solnix runs

A default Solnix system runs the illumos lex at /usr/bin/lex, published in pkgs.solnix.illumos-world-man. No other variants are shipped. The page does not say whether flex is available as a separate package.

Differences

Compared withTopicWhat differs
FreeBSDimplementationSolnix lex is the illumos lex. FreeBSD lex is a name for flex, 'fast lexical analyzer generator', and the page documents flex options. Both write lex.yy.c by default.
Source: Solnix lex(1) NAME, DESCRIPTION; FreeBSD lex(1) NAME, DESCRIPTION
FreeBSD-w meaningSolnix lex -w generates a program that handles EUC characters, with yytext[] as wchar_t[]. FreeBSD flex -w (--nowarn) suppresses warning messages. The same flag has unrelated effects.
Source: Solnix lex(1) -w; FreeBSD lex(1) -w, --nowarn
FreeBSD-e and EUC supportSolnix lex has -e for EUC characters, with yytext[] as unsigned char[]; it cannot be combined with -w. The FreeBSD synopsis and option list have no -e.
Source: Solnix lex(1) SYNOPSIS, -e; FreeBSD lex(1) SYNOPSIS
FreeBSD-c and -nOn Solnix, -c selects C-language actions (the default) and -n suppresses the -v statistics summary. On FreeBSD both are do-nothing, deprecated options kept for POSIX compliance. -n does not change FreeBSD output.
Source: Solnix lex(1) -c, -n; FreeBSD lex(1) -c, -n
FreeBSD-v statisticsBoth write a statistics summary to standard error with -v. Solnix ties it to table sizes in the lex source: -n is implied if no sizes are given and -v is absent. FreeBSD's summary starts with the flex version and the flags used.
Source: Solnix lex(1) -v, -n; FreeBSD lex(1) -v, --verbose
FreeBSDSolnix-only optionsSolnix has -Q[y|n] to put version information into lex.yy.c (-Qn is the default), -V to print version information on standard error, and -Y directory for an alternate driver-file directory. The FreeBSD synopsis has no -Q or -Y.
Source: Solnix lex(1) -Q, -V, -Y; FreeBSD lex(1) SYNOPSIS
FreeBSDflex-only optionsFreeBSD flex has -s (no default rule), -i (case-insensitive scanner), -l (AT&T lex compatibility mode), -b, -d, -f, -F, -p, -B, -I, -C, -o output, -P prefix and -S skeleton. The Solnix page documents none of these.
Source: FreeBSD lex(1) SYNOPSIS, OPTIONS; Solnix lex(1) SYNOPSIS
FreeBSDlong optionsFreeBSD flex accepts long options such as --stdout, --verbose, --help and --version. The Solnix page documents only single-letter options, so a script using --stdout for -t fails on Solnix.
Source: FreeBSD lex(1) SYNOPSIS, -t --stdout; Solnix lex(1) SYNOPSIS, OPTIONS
FreeBSDinput filesOn Solnix, several file operands are concatenated into one lex program, and a file operand of - means standard input, as does no operand. FreeBSD reads standard input when no file names are given; the visible text does not mention -.
Source: Solnix lex(1) OPERANDS; FreeBSD lex(1) DESCRIPTION
FreeBSDlocale handlingSolnix says lex is not fully internationalized for regular expressions in the source or the generated analyzer. It lists LANG, LC_ALL, LC_COLLATE, LC_CTYPE, LC_MESSAGES and NLSPATH as affecting lex. The FreeBSD text in the bundle lists no environment variables.
Source: Solnix lex(1) USAGE, ENVIRONMENT VARIABLES; FreeBSD lex(1) (no ENVIRONMENT section in bundle)
FreeBSDexit statusSolnix lex returns 0 on success and >0 on error, and the state of lex.yy.c is unspecified after a non-zero exit. The FreeBSD text in the bundle does not document exit status.
Source: Solnix lex(1) DESCRIPTION, EXIT STATUS; FreeBSD lex(1) (no EXIT STATUS in bundle)

Standards

  • POSIX: lex is a POSIX.1-2024 utility.
  • Solnix: Interface Stability: Standard. The page says generated C programs conform to the ISO C standard.
  • FreeBSD: -c and -n are described as do-nothing options included for POSIX compliance; -l gives maximum but not full compatibility with the original AT&T lex.

Writing portable scripts

  • Use only -t, -v and file operands in portable scripts. Redirect output yourself if you need a fixed name. Avoid -w, -e, -n and -c, which differ between illumos lex and flex.
  • Do not rely on long options, -s, -i, -l, -o or -P. They exist only in the FreeBSD flex text, not in the Solnix page.

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.