add output file for last top of stack

This commit is contained in:
yargo-moni 2017-03-10 16:09:48 +01:00
parent 5812333583
commit 532fb8c3ec
2 changed files with 11 additions and 3 deletions

View File

@ -13,6 +13,8 @@ This wrapper renders `dc` more usable as a command line calculator by:
- defining commonly used macros for more complex operations
- saving precision, top of stack, and registers 0 to 9 ("memories")
from one invocation to the next in the status file `$HOME/.wdcrc`
- saving last top of stack value in `$HOME/wdc` for further direct use
(change file name in the source, if desired)
# PREREQUISITES
@ -160,8 +162,10 @@ only at the very end. Otherwise, e.g the `rem` command would first have its
# FILES
The status between invocations is stored in the file `$HOME/.wdcrc` as a
list of `dc` commands.
- The status between invocations is stored in the file `$HOME/.wdcrc` as a list of `dc` commands.
- The last top of stack value is stored in `$HOME/wdc`.
_These file names can be easily changed at the beginning of the script._
# BUGS

View File

@ -1,8 +1,10 @@
#!/bin/sh
# wrapper for dc
info="wrapper for dc // 2016-11-22 Y.Bonetti // see https://gitlab.com/yargo/wrapdc"
info="wrapper for dc // 2017-03-10 Y.Bonetti // see https://gitlab.com/yargo/wrapdc"
# global status file
statf=$HOME/.wdcrc
# output file (last stack top)
outf=$HOME/wdc
# clear state: precision 2, clear stack and reg.0..9
clstat='2k 0 0 0 0 0 0s00s10s20s30s40s50s60s70s80s9'
if test ! -r $statf
@ -112,6 +114,8 @@ LEl:x[
# divide stack top by 10^A and print, print A
lA10lAZLAX-1-sAlA^/n[E]nLAp
ENDOFDCINPUT
# save stack top in output file for further direct processing
tail -n 1 $statf | sed -e 's/ *#.*//' >$outf
# print stack top
tail -n 1 $statf
}