diff options
Diffstat (limited to 'Functions/Misc')
-rw-r--r-- | Functions/Misc/run-help | 4 | ||||
-rw-r--r-- | Functions/Misc/zcalc | 28 | ||||
-rw-r--r-- | Functions/Misc/zmv | 15 |
3 files changed, 40 insertions, 7 deletions
diff --git a/Functions/Misc/run-help b/Functions/Misc/run-help index 6a9abb3cf..c817b67d6 100644 --- a/Functions/Misc/run-help +++ b/Functions/Misc/run-help @@ -56,6 +56,10 @@ do [[ -n $noalias && $what = *" is an alias "* ]] && continue builtin print -r $what case $what in + (*( is an alias for (noglob|nocorrect))*) + [[ ${what[(w)7]:t} != ${what[(w)1]} ]] && + run_help_orig_cmd=${what[(w)1]} run-help ${what[(w)7]:t} + ;; (*( is an alias)*) [[ ${what[(w)6]:t} != ${what[(w)1]} ]] && run_help_orig_cmd=${what[(w)1]} run-help ${what[(w)6]:t} diff --git a/Functions/Misc/zcalc b/Functions/Misc/zcalc index 2d0cf5d40..e9dcc78b9 100644 --- a/Functions/Misc/zcalc +++ b/Functions/Misc/zcalc @@ -114,7 +114,7 @@ float PI E (( PI = 4 * atan(1), E = exp(1) )) # Process command line -while [[ -n $1 && $1 = -(|[#-]*) ]]; do +while [[ -n $1 && $1 = -(|[#-]*|f) ]]; do optlist=${1[2,-1]} shift [[ $optlist = (|-) ]] && break @@ -139,6 +139,9 @@ while [[ -n $1 && $1 = -(|[#-]*) ]]; do fi defbase="[#${arg}]" ;; + (f) # Force floating point operation + setopt forcefloat + ;; esac done done @@ -152,7 +155,25 @@ for (( num = 1; num <= $#; num++ )); do done psvar[1]=$num -while vared -cehp "${ZCALCPROMPT}" line; do +local prev_line cont_prompt +while vared -cehp "${cont_prompt}${ZCALCPROMPT}" line; do + if [[ $line = (|*[^\\])('\\')#'\' ]]; then + prev_line+=$line[1,-2] + cont_prompt="..." + line= + continue + fi + 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. @@ -165,6 +186,7 @@ while vared -cehp "${ZCALCPROMPT}" line; do defbase=$match[1] fi print -s -- $line + print -- $(( ${defbase} ans )) line= continue else @@ -220,7 +242,7 @@ while vared -cehp "${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 diff --git a/Functions/Misc/zmv b/Functions/Misc/zmv index 4ba664e6d..269fe5ba5 100644 --- a/Functions/Misc/zmv +++ b/Functions/Misc/zmv @@ -93,7 +93,11 @@ # -p <program> # Call <program> instead of cp, ln or mv. Whatever it does, it should # at least understand the form '<program> -- <oldname> <newname>', -# where <oldname> and <newname> are filenames generated. +# where <oldname> and <newname> are filenames generated. <program> +# will be split into words. +# -P <program> +# As -p, but the program doesn't understand the "--" convention. +# In this case the file names must already be sane. # -w Pick out wildcard parts of the pattern, as described above, and # implicitly add parentheses for referring to them. # -W Just like -w, with the addition of turning wildcards in the @@ -123,14 +127,16 @@ setopt extendedglob local f g args match mbegin mend files action myname tmpf opt exec local opt_f opt_i opt_n opt_q opt_Q opt_s opt_M opt_C opt_L -local opt_o opt_p opt_v opt_w opt_W MATCH MBEGIN MEND +local opt_o opt_p opt_P opt_v opt_w opt_W MATCH MBEGIN MEND local pat repl errstr fpat hasglobqual opat typeset -A from to integer stat +local dashes=-- + myname=${(%):-%N} -while getopts ":o:p:MCLfinqQsvwW" opt; do +while getopts ":o:p:P:MCLfinqQsvwW" opt; do if [[ $opt = "?" ]]; then print -r -- "$myname: unrecognized option: -$OPTARG" >&2 return 1 @@ -144,6 +150,7 @@ done [[ -n $opt_C ]] && action=cp [[ -n $opt_L ]] && action=ln [[ -n $opt_p ]] && action=$opt_p +[[ -n $opt_P ]] && action=$opt_P dashes= if [[ -z $action ]]; then action=$myname[-2,-1] @@ -278,7 +285,7 @@ fi for f in $files; do [[ -z $to[$f] ]] && continue - exec=($action ${=opt_o} $opt_s -- $f $to[$f]) + exec=(${=action} ${=opt_o} $opt_s $dashes $f $to[$f]) [[ -n $opt_i$opt_n$opt_v ]] && print -r -- ${(q-)exec} if [[ -n $opt_i ]]; then read -q 'opt?Execute? ' || continue |