From ab8fe84a8c179f5990c4fd7cd7e2cfa82ed03cc3 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 17 Mar 2013 20:52:55 +0000 Subject: 31155: minor extra zcalc features and documentation --- Functions/Misc/zcalc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Functions') diff --git a/Functions/Misc/zcalc b/Functions/Misc/zcalc index d78c35ed2..e9dcc78b9 100644 --- a/Functions/Misc/zcalc +++ b/Functions/Misc/zcalc @@ -166,6 +166,14 @@ while vared -cehp "${cont_prompt}${ZCALCPROMPT}" line; do line="$prev_line$line" prev_line= cont_prompt= + # Test whether there are as many open as close + # parentheses in the line so far. + if [[ ${#line//[^\(]} -gt ${#line//[^\)]} ]]; then + prev_line+=$line + cont_prompt="..." + line= + continue + fi [[ -z $line ]] && break # special cases # Set default base if `[#16]' or `[##16]' etc. on its own. @@ -178,6 +186,7 @@ while vared -cehp "${cont_prompt}${ZCALCPROMPT}" line; do defbase=$match[1] fi print -s -- $line + print -- $(( ${defbase} ans )) line= continue else @@ -233,7 +242,7 @@ while vared -cehp "${cont_prompt}${ZCALCPROMPT}" line; do continue ;; - ((:|)function[[:blank:]]##(#b)([^[:blank:]]##)(|[[:blank:]]##([^[:blank:]]*))) + ((function|:f(unc(tion|)|))[[:blank:]]##(#b)([^[:blank:]]##)(|[[:blank:]]##([^[:blank:]]*))) zmathfuncdef $match[1] $match[3] line= continue -- cgit 1.4.1