[TUHS] Etymology of bc(1)

random832 at fastmail.us random832 at fastmail.us
Fri Sep 12 23:37:16 AEST 2014


On Thu, Sep 11, 2014, at 21:03, Dave Horsfall wrote:
> On the *nix systems to which I have access, bc(1) is a standalone
> program on FreeBSD and OSX, but pipes to dc(1) on OpenBSD.

What language does the undocumented option (assuming it is supported at
all) "bc -c" generate on FreeBSD and OSX? "Standard" bc, which actually
pipes to dc, generates (obviously) dc when run in this way, but GNU bc
generates a completely different and as far as I know undocumented
language, which is handled by the execute function (in execute.c) but as
far as I know there is no way to make it accept it on standard input.

Standard bc:
$ echo '2+2' | bc -c
 2 2+ps.
q$

GNU bc:
$ echo '2+2' | bc -c
@iK2:K2:+W at r
@i
$


(the @i and @r pseudo-instructions are printed separately from the
generated code when in -c mode [util.c], and are not part of the
language passed to the execute function.)



More information about the TUHS mailing list