diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2001-12-07 12:59:08 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2001-12-07 12:59:08 +0000 |
commit | 64b4bfe6fc8ae3e12bfdc4b5f776fa5d2cc02d24 (patch) | |
tree | c37564e424ea1c91c2bd6197fa06a97f094dc248 /Functions | |
parent | 960a7e534702b487d82b28dde99053db6f33b992 (diff) | |
download | zsh-64b4bfe6fc8ae3e12bfdc4b5f776fa5d2cc02d24.tar.gz zsh-64b4bfe6fc8ae3e12bfdc4b5f776fa5d2cc02d24.tar.xz zsh-64b4bfe6fc8ae3e12bfdc4b5f776fa5d2cc02d24.zip |
* 16310: Functions/Misc/zcalc, Doc/Zsh/contrib.yo: separate zcalc
history, handle errors in expression, document -#base option.
Diffstat (limited to 'Functions')
-rw-r--r-- | Functions/Misc/zcalc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Functions/Misc/zcalc b/Functions/Misc/zcalc index 5d0264922..5e01e73d0 100644 --- a/Functions/Misc/zcalc +++ b/Functions/Misc/zcalc @@ -88,6 +88,25 @@ emulate -L zsh setopt extendedglob +# can't be local since required in EXIT trap +zcalc_orighist=$HISTFILE +local temphist=${TMPPREFIX}hist SAVEHIST=$HISTSIZE +HISTFILE=$temphist +fc -W + +local HISTSIZE=0 +HISTSIZE=$SAVEHIST +HISTFILE=~/.zcalc_history +[[ -f $HISTFILE ]] && fc -R + +zcalc_restore() { + unfunction zcalc_restore + fc -W + HISTFILE=$zcalc_orighist + fc -R +} +trap zcalc_restore HUP INT QUIT EXIT + local line latest base defbase match mbegin mend psvar optlist opt arg integer num @@ -172,7 +191,10 @@ while vared -cehp "${(%)ZCALCPROMPT}" line; do # # Since it's a string, we'd better make sure we know which # base it's in, so don't change that until we actually print it. + latest= eval "latest=\$(( $line ))" + # on error $latest is not set; let user re-edit line + [[ -n $latest ]] || continue argv[num++]=$latest psvar[1]=$num if [[ -z $base ]]; then |