[PATCH] dc: support GNU dc options (-e/--expression -f/--file)

wdlkmpx wdlkmpx at gmail.com
Thu Apr 5 19:52:18 UTC 2018


I see the patch title might be misleading.. this just adds a
compatibility layer through -e and -f, but does not implement any
additional DC commands. In fact i'm reading the gnu dc manual for the
first time ahaha.

The busybox dc can be considered a subset of the gnu dc.. with a few
incompatibilies... the gnu dc does not recognize 'add mul mod div' but
'+ * % /' etc.. the busybox dc recognizes both..

Testing the patch..

In this quick test providing the same "portable" params you can see
that both dc's behave the same..

However this is something i just found out:
The busybox dc expects a EXPRESSION if no -opts are provided.. this is
the default behavior that is not changing... but the gnu dc expects a
FILE if no -opts are provided...

// BUSYBOX DC

# ./busybox dc "10 10 * p"
100

# ./busybox dc -e
dc: option requires an argument -- 'e'
...
# ./busybox dc -e "10 10 * p"
100
# ./busybox dc --expression=

# ./busybox dc --expresion="10 10 * p"
100

# echo "10 10 * p" > dc.in

# ./busybox dc -f dc.in
100
# ./busybox dc --file=
dc: : No such file or directory
# ./busybox dc --file=dc.in
100
# ./busybox dc -a
dc: invalid option -- 'a'



// GNU DC

# dc "10 10 * p"
dc: Could not open file 10 10 * p

# dc -e
dc: option requires an argument -- 'e'
.....
# dc -e "10 10 * p"
100
# dc --expression=

# dc --expression="10 10 * p"
100

# echo "10 10 * p" > dc.in

# dc -f dc.in
100
# dc --file=
dc: Could not open file
# dc --file=dc.in
100
# dc -a
dc: invalid option -- 'a'


More information about the busybox mailing list