bc(1) on Solnix vs Linux and the BSDs
On Solnix, bc is the illumos bc at /usr/bin/bc. It is a front end that compiles bc code to dc input and runs dc. It takes only -c and -l, plus files. Linux, NetBSD and FreeBSD ship bc programs with different option sets, and -c means something else on FreeBSD.
The manual pages
- Solnix: bc(1) from
pkgs.solnix.illumos-world-man· illumos.org - Linux: bc(1) bc-1.08.2
- FreeBSD: bc(1) 15.1-RELEASE
- OpenBSD: bc(1) 8.0
- NetBSD: bc(1) 11.0
- Standard: POSIX.1-2024 (IEEE Std 1003.1-2024),
bc
What Solnix runs
A default Solnix system runs the illumos /usr/bin/bc. /usr/xpg6/bin/bc is also shipped with the same synopsis. The only documented difference is that with -l the xpg6 page adds 'All math results have the scale of 20.' The /usr/bin/bc page says only that -l initializes scale to 20.
Differences
| Compared with | Topic | What differs |
|---|---|---|
| FreeBSD | -c meaning | Solnix -c means compile only: dc commands go to standard output. On FreeBSD, -c (--digit-clamp) turns on clamping of digits at or above ibase, and the page does not describe a compile-only mode. A script using bc -c gets a different behaviour on FreeBSD.Source: Solnix bc(1) OPTIONS -c; FreeBSD bc(1) OPTIONS -c, --digit-clamp |
| Linux, NetBSD | no -c | Linux and NetBSD list no -c option. Their options are -h, -i, -l, -q, -s, -v and -w. Solnix and OpenBSD describe -c as printing the generated dc input instead of running it.Source: Linux bc(1) OPTIONS; NetBSD bc(1) SYNOPSIS, OPTIONS; Solnix bc(1) OPTIONS -c; OpenBSD bc(1) -c |
| FreeBSD, OpenBSD | -e expression | FreeBSD and OpenBSD bc accept -e to evaluate an expression given on the command line. Solnix bc has no -e; it takes only file operands and then reads standard input, so feed expressions through stdin.Source: FreeBSD bc(1) -e, --expression; OpenBSD bc(1) SYNOPSIS, -e; Solnix bc(1) SYNOPSIS, OPERANDS |
| Linux, FreeBSD, NetBSD | missing GNU-style options | Solnix has no -s, -w, -q, -i or -v and no long options. Linux and NetBSD offer -s/--standard, -w/--warn, -q/--quiet, -i/--interactive and -v/--version. FreeBSD offers similar long options. Scripts passing -q to hide the banner fail on Solnix.Source: Solnix bc(1) SYNOPSIS; Linux bc(1) OPTIONS; NetBSD bc(1) OPTIONS; FreeBSD bc(1) SYNOPSIS |
| FreeBSD | FreeBSD-only options and environment | FreeBSD bc adds -f, -g, -I ibase, -O obase, -S scale, -E seed, -r keyword, and the environment variables BC_DIGIT_CLAMP and BC_ENV_ARGS. Solnix documents only LANG, LC_ALL, LC_CTYPE, LC_MESSAGES and NLSPATH.Source: FreeBSD bc(1) SYNOPSIS, OPTIONS, ENVIRONMENT VARIABLES; Solnix bc(1) ENVIRONMENT VARIABLES |
| OpenBSD | && and || operators | Solnix bc does not recognize && and ||. OpenBSD documents !, && and || as non-portable extensions. A condition written with && or || works on OpenBSD but not on Solnix. Source: Solnix bc(1) NOTES; OpenBSD bc(1) Operators |
| OpenBSD | for statement | On Solnix, a for statement must have all three expressions. On OpenBSD all three may be empty, which the page calls a non-portable extension. Source: Solnix bc(1) NOTES; OpenBSD bc(1) Statements |
| Linux, OpenBSD, NetBSD | # comments and last | Solnix documents only /* */ comments and has no 'last' variable. Linux, NetBSD and OpenBSD accept # line comments and 'last' as extensions. OpenBSD also accepts a single dot for last. Scripts using # comments will not parse on Solnix. Source: Solnix bc(1) Comments, Names; Linux bc(1) COMMENTS, VARIABLES; NetBSD bc(1) COMMENTS; OpenBSD bc(1) Comments, Names |
| OpenBSD | if-else, continue, print | The Solnix statement list has if without else, while, for, break and quit. OpenBSD adds if/else, continue and print as non-portable extensions. The Solnix page does not mention them. Source: Solnix bc(1) Statements; OpenBSD bc(1) Statements |
| Linux, OpenBSD, NetBSD | variable names | The Solnix page defines L as a single letter a-z. Linux, NetBSD and OpenBSD allow longer names as an extension, so multi-letter names are not documented on Solnix. Source: Solnix bc(1) USAGE; Linux bc(1) VARIABLES; NetBSD bc(1) VARIABLES; OpenBSD bc(1) DESCRIPTION |
| all four | -l and scale | Solnix -l defines the math functions and sets scale to 20. The Linux, NetBSD and OpenBSD pages say only that -l defines or includes the math library, and the shown text gives no scale. Set scale explicitly in portable scripts.Source: Solnix bc(1) OPTIONS -l; Linux bc(1) -l; NetBSD bc(1) -l; OpenBSD bc(1) -l |
| Linux, FreeBSD, NetBSD | implementation | Solnix and OpenBSD describe bc as a preprocessor that runs dc. The Linux and NetBSD pages describe bc as the language processor itself, and FreeBSD calls its bc a drop-in replacement for GNU bc. The Solnix page does not claim GNU compatibility. Source: Solnix bc(1) DESCRIPTION; OpenBSD bc(1) -c; Linux bc(1) DESCRIPTION; NetBSD bc(1) DESCRIPTION; FreeBSD bc(1) DESCRIPTION |
| all four | exit status | Solnix documents 0 for success and 'unspecified' for any error, so scripts cannot rely on specific nonzero codes. Source: Solnix bc(1) EXIT STATUS |
Standards
- POSIX: bc is a POSIX.1-2024 utility.
- Solnix: ATTRIBUTES: Interface Stability is Standard. SEE ALSO lists standards(7).
- FreeBSD: bc is described as an interactive processor for a language first standardized in 1991 by POSIX (see its STANDARDS section).
- OpenBSD: The page cites IEEE Std 1003.1-2008 (“POSIX.1”), which allows relational operators only in the condition of if, while or for.
- Linux: The page says this bc has extensions beyond traditional bc and the POSIX draft standard;
-sprocesses exactly the POSIX bc language. - NetBSD: The page says this bc has extensions beyond traditional bc and the POSIX draft standard;
-sprocesses exactly the POSIX bc language.
Writing portable scripts
- Use only
-land file or stdin input, for example: echo 'scale=4; 2/3' | bc-l. Avoid-c,-e,-qand long options. - Avoid && and ||, # comments, 'last', long variable names and for statements with empty parts. Solnix does not support them.
- Set scale explicitly in the script instead of relying on
-l's default.
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.