GEXPR
------
This is gexpr, a shell calculator that I hope you'll find handy. gexpr is
similar to the expr(1) command, but it supports floating point math. I wrote
it just for fun, but also because IMHO bc(1) is not intuitive to use.
gexpr supports all standard C math and adds a few nice features -- see the
man page. You use gexpr as a simple calculator. Examples:
$ gexpr "1+1"
$ gexpr "sqrt(PI)"
$ gexpr "fact(5) / pow(2, 4)"
$ gexpr "log10(sin(PI/8)) < exp(1)/3"
$ gexpr "${X} * 1.24"
Note that you can use shell variables, so using gexpr in shell scripts can
be interesting. (I actually use gexpr in shell scripts to create short data
files.) The built-in variables are the same as C, plus relational operators
( < <= > >= == != ), fact(), and rnd(). Adding your personal functions is
easy -- use the source.
INSTALL
--------
To build it, type as root:
# make
# make install
# make clean
Although I only tried to install gexpr under Linux, DOS/Windows, and Digital
Unix, any machine supporting an ANSI C compiler (e.g. gcc) should be a
target. Let me know.
RPM BUILD
----------
On Red Hat and derivatives, you can build an .rpm for gexpr with this
command:
# rpm -ta gexpr-2.0.2.tar.gz.
Then find out where the .rpm was created, and install it as usual:
# rpm -i gexpr-2.0.2-1.i386.rpm
COPYING POLICY
---------------
gexpr is under GPL. If you don't know what that means, please read the
accompanying file COPYING.
TO DO
------
Still a bit messy, needs polishing. It uses (shock horror) global variables
and longjmp. It would be nice if the parsing routine were completely
stand-alone, and easily reusable. No line editing. These problems will be
addressed in the next version.
AUTHOR
-------
gexpr was written by Guido Gonzato, <ggonza@tin.it>. For any problems,
suggestions for better parsing algorithms, and whatever you think, feel free
to contact me.
Ciao,
Guido =8-)