From 6265394d6bc431b9e972aaeccc29582a5694f842 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 24 Jan 2013 20:28:20 +0000 Subject: users/17608: use function to modify currrent command line argument --- Doc/Zsh/contrib.yo | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'Doc/Zsh/contrib.yo') diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 8dbc095fd..00f70a2bf 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -2477,15 +2477,22 @@ See the function tt(modify-current-argument), described below, for an example of how to call this function. ) tindex(modify-current-argument) -item(tt(modify-current-argument) var(expr-using-)tt($ARG))( +item(tt(modify-current-argument) [ var(expr-using-)tt($ARG) | var(func) ])( This function provides a simple method of allowing user-defined widgets to modify the command line argument under the cursor (or immediately to the -left of the cursor if the cursor is between arguments). The argument -should be an expression which when evaluated operates on the shell +left of the cursor if the cursor is between arguments). + +The argument can be an expression which when evaluated operates on the shell parameter tt(ARG), which will have been set to the command line argument under the cursor. The expression should be suitably quoted to prevent it being evaluated too early. +Alternatively, if the argument does not contain the string tt(ARG), it +is assumed to be a shell function, to which the current command line +argument is passed as the only argument. The function should set the +variable tt(REPLY) to the new value for the command line argument. +If the function returns non-zero status, so does the calling function. + For example, a user-defined widget containing the following code converts the characters in the argument under the cursor into all upper case: @@ -2497,6 +2504,18 @@ or one of the styles of quotes), and replaces it with single quoting throughout: example(modify-current-argument '${(qq)${(Q)ARG}}') + +The following performs directory expansion on the command line +argument and replaces it by the absolute path: + +example(expand-dir() { + REPLY=${~1} + REPLY=${REPLY:a} +} +modify-current-argument expand-dir) + +In practice the function tt(expand-dir) would probably not be defined +within the widget where tt(modify-current-argument) is called. ) enditem() -- cgit v1.2.3 From 2b75cf571e45fae6344ee6681a2d4418ab5ea165 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Sat, 26 Jan 2013 22:54:01 +0000 Subject: 31000: fix typo in example --- ChangeLog | 6 +++++- Doc/Zsh/contrib.yo | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'Doc/Zsh/contrib.yo') diff --git a/ChangeLog b/ChangeLog index 1e1bab72d..a802a6a69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-01-26 Bart Schaefer + + * 31000: Doc/Zsh/contrib.yo: fix typo in example. + 2013-01-24 Peter Stephenson * users/17608: Doc/Zsh/contrib.yo, @@ -467,5 +471,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5789 $ +* $Revision: 1.5790 $ ***************************************************** diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 00f70a2bf..41a9d8158 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -2508,7 +2508,7 @@ example(modify-current-argument '${(qq)${(Q)ARG}}') The following performs directory expansion on the command line argument and replaces it by the absolute path: -example(expand-dir() { +example(expand-dir+LPAR()RPAR() { REPLY=${~1} REPLY=${REPLY:a} } -- cgit v1.2.3 From 26694406f22f0fe37d0b751066200bf0cfdec165 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 5 Mar 2013 20:06:59 +0000 Subject: users/17666: zcalc -f sets FORCE_FLOAT --- ChangeLog | 5 ++++- Doc/Zsh/contrib.yo | 4 ++++ Functions/Misc/zcalc | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'Doc/Zsh/contrib.yo') diff --git a/ChangeLog b/ChangeLog index 19df9d5df..0cdc86d19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2013-03-05 Peter Stephenson + * users/17666: Doc/Zsh/contrib.yo, Functions/Misc/zcalc: -f + option to zcalc sets FORCE_FLOAT. + * users/17665: Doc/Zsh/options.yo, Src/math.c, Src/options.c, Src/zsh.h, Test/C01arith.ztst: add FORCE_FLOAT option. @@ -558,5 +561,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5811 $ +* $Revision: 1.5812 $ ***************************************************** diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 41a9d8158..14886d676 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -3158,6 +3158,10 @@ The output base can be initialised by passing the option `tt(-#)var(base)', for example `tt(zcalc -#16)' (the `tt(#)' may have to be quoted, depending on the globbing options set). +If the option `tt(-f)' is set, all numbers are treated as floating +point, hence for example the expression `tt(3/4)' evaluates to 0.75 +rather than 0. Options must appear in separate words. + The prompt is configurable via the parameter tt(ZCALCPROMPT), which undergoes standard prompt expansion. The index of the current entry is stored locally in the first element of the array tt(psvar), which can be diff --git a/Functions/Misc/zcalc b/Functions/Misc/zcalc index 2d0cf5d40..3d44f20db 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 -- cgit v1.2.3 From dcbeba98898463acc213b7b55fc09a74d6a2e60b Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Wed, 13 Mar 2013 19:49:02 +0000 Subject: unposted: adjust another mention of psvar --- ChangeLog | 7 ++++++- Doc/Zsh/contrib.yo | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'Doc/Zsh/contrib.yo') diff --git a/ChangeLog b/ChangeLog index c386f27fd..f4f3a1990 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-03-13 Mikael Magnusson + + * unposted: Doc/Zsh/contrib.yo: Also adjust a mention of psvar + in the vcs info documentation. + 2013-03-13 Peter Stephenson * unposted, c.f. thread from 31144: Doc/Zsh/params.yo: all psvar @@ -588,5 +593,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5818 $ +* $Revision: 1.5819 $ ***************************************************** diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 14886d676..227914105 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -619,7 +619,7 @@ To load tt(vcs_info): example(autoload -Uz vcs_info) It can be used in any existing prompt, because it does not require any -tt($psvar) entries to be left available. +specific tt($psvar) entries to be available. subsect(Quickstart) -- cgit v1.2.3 From 136cc1e1b79ebc07f5deb630fea9d325276d077c Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 15 Mar 2013 20:15:10 +0000 Subject: 31154: make zcalc understand continuation lines with a backslash --- ChangeLog | 7 ++++++- Doc/Zsh/contrib.yo | 7 ++++++- Functions/Misc/zcalc | 12 +++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) (limited to 'Doc/Zsh/contrib.yo') diff --git a/ChangeLog b/ChangeLog index 06751df8b..4a56f1503 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-03-15 Peter Stephenson + + * 31154: Doc/Zsh/contrib.yo, Functions/Misc/zcalc: make zcalc + understand continuation lines using backslash. + 2013-03-14 Peter Stephenson * 31151: Pavol Juhas: complete (C etc) tags better @@ -603,5 +608,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5821 $ +* $Revision: 1.5822 $ ***************************************************** diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 227914105..f13aa79cf 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -3144,7 +3144,12 @@ line preceded by `tt(4> )' is available as tt($4). The last value calculated is available as tt(ans). Full command line editing, including the history of previous calculations, is available; the history is saved in the file tt(~/.zcalc_history). To exit, enter a blank line or type `tt(:q)' -on its own (`tt(q)' is allowed for historical compatibility). +on its own (`tt(q)' is allowed for historical compatibility). A +line ending with a single backslash is treated in the same fashion +as it is in command line editing: the backslash is removed, the +function prompts for more input (the prompt is preceded by `tt(...)' +to indicate this), and the lines are combined into one to get the final +result. If arguments are given to tt(zcalc) on start up, they are used to prime the first few positional parameters. A visual indication of this is given when diff --git a/Functions/Misc/zcalc b/Functions/Misc/zcalc index 3d44f20db..d78c35ed2 100644 --- a/Functions/Misc/zcalc +++ b/Functions/Misc/zcalc @@ -155,7 +155,17 @@ 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= [[ -z $line ]] && break # special cases # Set default base if `[#16]' or `[##16]' etc. on its own. -- cgit v1.2.3 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 --- ChangeLog | 7 ++++++- Doc/Zsh/contrib.yo | 12 ++++++++---- Functions/Misc/zcalc | 11 ++++++++++- 3 files changed, 24 insertions(+), 6 deletions(-) (limited to 'Doc/Zsh/contrib.yo') diff --git a/ChangeLog b/ChangeLog index 4a56f1503..8302b27cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-03-17 Peter Stephenson + + * 31155: Doc/Zsh/contrib.yo, Functions/Misc/zcalc: minor + extra zcalc features and documentation. + 2013-03-15 Peter Stephenson * 31154: Doc/Zsh/contrib.yo, Functions/Misc/zcalc: make zcalc @@ -608,5 +613,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5822 $ +* $Revision: 1.5823 $ ***************************************************** diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index f13aa79cf..b191e10d9 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -3144,12 +3144,14 @@ line preceded by `tt(4> )' is available as tt($4). The last value calculated is available as tt(ans). Full command line editing, including the history of previous calculations, is available; the history is saved in the file tt(~/.zcalc_history). To exit, enter a blank line or type `tt(:q)' -on its own (`tt(q)' is allowed for historical compatibility). A -line ending with a single backslash is treated in the same fashion +on its own (`tt(q)' is allowed for historical compatibility). + +A line ending with a single backslash is treated in the same fashion as it is in command line editing: the backslash is removed, the function prompts for more input (the prompt is preceded by `tt(...)' to indicate this), and the lines are combined into one to get the final -result. +result. In addition, if the input so far contains more open than +close parentheses tt(zcalc) will prompt for more input. If arguments are given to tt(zcalc) on start up, they are used to prime the first few positional parameters. A visual indication of this is given when @@ -3219,11 +3221,13 @@ scope. ) item(tt(:function) var(name) [ var(body) ])( Define a mathematical function or (with no var(body)) delete it. +tt(:function) may be abbreviated to tt(:func) or simply tt(:f). +The var(name) may contain the same characters as a shell function name. The function is defined using tt(zmathfuncdef), see below. Note that tt(zcalc) takes care of all quoting. Hence for example: -example(function cube $1 * $1 * $1) +example(:f cube $1 * $1 * $1) defines a function to cube the sole argument. ) 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 v1.2.3 From 669c070efe06d1820ccb32adaa6b1512279401ab Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 3 Jul 2013 12:46:02 +0100 Subject: 31503: zmv improvements for user-specified programs. -p splits words of commands passed to it. -P is like -p for when the program doesn't understand the -- convention --- ChangeLog | 6 ++++++ Doc/Zsh/contrib.yo | 10 ++++++++-- Functions/Misc/zmv | 15 +++++++++++---- 3 files changed, 25 insertions(+), 6 deletions(-) (limited to 'Doc/Zsh/contrib.yo') diff --git a/ChangeLog b/ChangeLog index 33ff8f0b9..403d04234 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-07-03 Peter Stephenson + + * 31503: Doc/Zsh/contrib.yo, Functions/Misc/zmv: split words + in program passed to zmv with -p and add -P for programs + that don't understand the "--" convention. + 2013-06-28 Clint Adams * 31500: Completion/Debian/Command/_dput: dput-ng completion diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index b191e10d9..06e7ed076 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -3618,7 +3618,7 @@ ifzman(above)\ ifnzman((noderef(Utilities))). ) findex(zmv) -item(tt(zmv) [ tt(-finqQsvwW) ] [ -C | -L | -M | -p var(program) ] [ -o var(optstring) ] var(srcpat) var(dest) )( +item(tt(zmv) [ tt(-finqQsvwW) ] [ -C | -L | -M | -[pP] var(program) ] [ -o var(optstring) ] var(srcpat) var(dest) )( Move (usually, rename) files matching the pattern var(srcpat) to corresponding files having names of the form given by var(dest), where var(srcpat) contains parentheses surrounding patterns which will be @@ -3663,7 +3663,13 @@ sitem(tt(-p) var(program))(Call var(program) instead of tt(cp), tt(ln) or tt(mv). Whatever it does, it should at least understand the form ifzman(`var(program) tt(-)tt(-) var(oldname) var(newname)')\ ifnzman(example(var(program) tt(-)tt(-) var(oldname) var(newname))) -where var(oldname) and var(newname) are filenames generated by tt(zmv).) +where var(oldname) and var(newname) are filenames generated by tt(zmv). +var(program) will be split into words, so might be e.g. the name +of an archive tool plus a copy or rename subcommand.) +sitem(tt(-P) var(program))(As tt(-p) var(program), except that +var(program) does not accept a following tt(-)tt(-) to indicate the +end of options. In this case filenames must already be in a sane +form for the program in question.) sitem(tt(-o) var(optstring))(The var(optstring) is split into words and passed down verbatim to the tt(cp), tt(ln) or tt(mv) command called to perform the work. It should probably begin with a `tt(-)'.) 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 # Call instead of cp, ln or mv. Whatever it does, it should # at least understand the form ' -- ', -# where and are filenames generated. +# where and are filenames generated. +# will be split into words. +# -P +# 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 -- cgit v1.2.3 From 1c9931cc7d37cac9aebb034444fb87e0901e914a Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 29 Aug 2013 10:48:49 +0100 Subject: users/17955: new "disown" style for MIME handlers. Makes handlers put into the background run without job control. --- ChangeLog | 4 ++++ Doc/Zsh/contrib.yo | 8 ++++++++ Functions/MIME/zsh-mime-handler | 9 ++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) (limited to 'Doc/Zsh/contrib.yo') diff --git a/ChangeLog b/ChangeLog index 77c1991f2..7b93632f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2013-08-29 Peter Stephenson + * users/17955: Doc/Zsh/contrib.yo, + Functions/MIME/zsh-mime-handler: "disown" style makes MIME + handlers put into background run without job control. + * based on 31641, 31642: Completion/Unix/Command/_make: support a couple of different variants of make. diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 06e7ed076..48c510582 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -2861,6 +2861,14 @@ question is run using the tt(eval) builtin instead of by starting a new tt(sh) process. This is more efficient, but may not work in the occasional cases where the mailcap handler uses strict POSIX syntax. ) +kindex(disown, MIME style) +item(tt(disown))( +If this boolean style is true, mailcap handlers started in the +background will be disowned, i.e. not subject to job control within +the parent shell. Such handlers nearly always produce their own +windows, so the only likely harmful side effect of setting the style is +that it becomes harder to kill jobs from within the shell. +) kindex(execute-as-is, MIME style) item(tt(execute-as-is))( This style gives a list of patterns to be matched against files diff --git a/Functions/MIME/zsh-mime-handler b/Functions/MIME/zsh-mime-handler index abaf0b6e3..7245c20e2 100644 --- a/Functions/MIME/zsh-mime-handler +++ b/Functions/MIME/zsh-mime-handler @@ -74,7 +74,7 @@ if [[ $suffix != *.* ]]; then fi suffix=${suffix#*.} -local handler flags no_sh no_bg arg +local handler flags no_sh no_bg arg bg_flag="&" integer i local -a exec_asis hand_nonex @@ -89,6 +89,9 @@ zsh-mime-contexts -a $suffix execute-as-is exec_asis || exec_asis=('*(*)' '*(/)' zsh-mime-contexts -a $suffix handle-nonexistent hand_nonex || hand_nonex=('[[:alpha:]]#:/*') +# Set to true if the job should be disowned. +zsh-mime-contexts -t $suffix disown && bg_flag="&!" + local pattern local -a files @@ -309,8 +312,8 @@ else # Otherwise it's equivalent to removing the eval and all the quotes, # including the (q) flags. if [[ -n $stdin ]]; then - eval cat ${(q)argv} "|" ${(q)execargs} "&" + eval cat ${(q)argv} "|" ${(q)execargs} $bg_flag else - eval ${(q)execargs} "&" + eval ${(q)execargs} $bg_flag fi fi -- cgit v1.2.3 From 061e80950223501fbcb77e987a9a0dafedf6f229 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 8 Sep 2013 21:12:13 +0100 Subject: 31711: add execute-never style for MIME function system. Allows alien file systems to be marked as not having executable fiels --- ChangeLog | 6 ++++++ Doc/Zsh/contrib.yo | 22 ++++++++++++++++++++++ Functions/MIME/zsh-mime-handler | 6 +++++- 3 files changed, 33 insertions(+), 1 deletion(-) (limited to 'Doc/Zsh/contrib.yo') diff --git a/ChangeLog b/ChangeLog index 094956989..43167cc3a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-09-08 Peter Stephenson + + * 31711: Doc/Zsh/contrib.yo, Functions/MIME/zsh-mime-handler: + add execute-never style for MIME handler for files on alien file + systems. + 2013-09-06 Peter Stephenson * Luka Perkov: 31702: Completion/Unix/Command/_git: diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 48c510582..9d3fc7562 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -2881,6 +2881,28 @@ hence executable files are executed directly and not passed to a handler, and the option tt(AUTO_CD) may be used to change to directories that happen to have MIME suffixes. ) +kindex(execute-never, MIME style) +item(tt(execute-never))( +This style is useful in combination with tt(execute-as-is). It is +set to an array of patterns corresponding to full paths to files that +should never be treated as executable, even if the file passed to +the MIME handler matches tt(execute-as-is). This is useful for file +systems that don't handle execute permission or that contain executables +from another operating system. For example, if tt(/mnt/windows) is a +Windows mount, then + +example(zstyle ':mime:*' execute-never '/mnt/windows/*') + +will ensure that any files found in that area will be executed as MIME +types even if they are executable. As this example shows, the complete +file name is matched against the pattern, regardless of how the file +was passed to the handler. The file is resolved to a full path using +the tt(:A) modifier described in +ifzman(the subsection Modifers in zmanref(zshexpn))\ +ifnzman(noderef(Modifiers))); +this means that symbolic links are resolved where possible, so that +links into other file systems behave in the correct fashion. +) kindex(file-path, MIME style) item(tt(file-path))( Used if the style tt(find-file-in-path) is true for the same context. diff --git a/Functions/MIME/zsh-mime-handler b/Functions/MIME/zsh-mime-handler index 7245c20e2..24e5184fc 100644 --- a/Functions/MIME/zsh-mime-handler +++ b/Functions/MIME/zsh-mime-handler @@ -76,13 +76,14 @@ suffix=${suffix#*.} local handler flags no_sh no_bg arg bg_flag="&" integer i -local -a exec_asis hand_nonex +local -a exec_asis hand_nonex exec_never # Set to a list of patterns which are ignored and executed as they are, # despite being called for interpretation by the mime handler. # Defaults to executable files, which ensures that they are executed as # they are, even if they have a suffix. zsh-mime-contexts -a $suffix execute-as-is exec_asis || exec_asis=('*(*)' '*(/)') +zsh-mime-contexts -a $suffix execute-never exec_never # Set to a list of patterns for which the handler will be used even # if the file doesn't exist on the disk. @@ -125,6 +126,9 @@ fi for pattern in $exec_asis; do files=(${dirpref}${~pattern}) if [[ -n ${files[(r)$1]} ]]; then + for pattern in $exec_never; do + [[ ${1:A} = ${~pattern} ]] && break 2 + done if (( list )); then for (( i = 1; i <= $#; i++ )); do (( i == 1 )) || print -n " " -- cgit v1.2.3