From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1557 invoked by alias); 3 Jul 2014 15:59:24 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32833 Received: (qmail 486 invoked from network); 3 Jul 2014 15:59:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Biglobe-Sender: Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.2\)) Subject: Re: [Pkg-zsh-devel] Bug#679824: zsh: Buggy perl completion with -e [origin: vincent@vinc17.net] From: "Jun T." In-Reply-To: <461B8CB3-4C88-42D4-987F-3A9C3846EB03@kba.biglobe.ne.jp> Date: Fri, 4 Jul 2014 00:59:13 +0900 Content-Transfer-Encoding: quoted-printable Message-Id: <9EFC1491-C1F9-407F-B0A7-BFCC51414D51@kba.biglobe.ne.jp> References: <20140628142003.GI5355@sym.noone.org> <461B8CB3-4C88-42D4-987F-3A9C3846EB03@kba.biglobe.ne.jp> To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.1878.2) X-Biglobe-Spnum: 59092 2014/06/30 22:02, Jun T. wrote: > python -c '...' > ruby -e '...' >=20 > these will complete a command name, not a file name. The following is a patch to fix this. In the case of ruby, the current _ruby contains '(-)1:script file:_files' This means all files (foo.rb, bar.py, junk.c, etc.) are offered as Ruby scripts, but I didn't change this in the patch. I have no experience with ruby and don't know what most ruby users expect here. diff --git a/Completion/Unix/Command/_python = b/Completion/Unix/Command/_python index edc49b7..da84b30 100644 --- a/Completion/Unix/Command/_python +++ b/Completion/Unix/Command/_python @@ -24,12 +24,12 @@ fi =20 _arguments -C -s -S "$args[@]" \ "-B[don't write .py\[co\] files on import]" \ - '(1 -)-c+[program passed in as string (terminates option = list)]:python command:' \ + '(-)-c+[program passed in as string (terminates option list)]:python = command:' \ '-d[debug output from parser]' \ '-E[ignore PYTHON* environment variables (such as PYTHONPATH)]' \ '(1 * -)-h[display help information]' \ '-i[inspect interactively after running script]' \ - '(1 * -)-m[run library module as a script (terminates option = list)]:module:->modules' \ + '(-)-m[run library module as a script (terminates option = list)]:module:->modules' \ '-O[optimize generated bytecode slightly]' \ '-OO[remove doc-strings in addition to the -O optimizations]' \ "-s[don't add user site directory to sys.path]" \ @@ -39,16 +39,27 @@ _arguments -C -s -S "$args[@]" \ '(1 * -)-V[display version information]' \ '-W+[warning control]:warning filter = (action\:message\:category\:module\:lineno):(default always ignore = module once error)' \ '-x[skip first line of source, allowing use of non-Unix forms of = #!cmd]' \ - '(-)1:script file:_files -g "*.py(|c|o)(-.)"' \ + '(-)1:script_or_arg:->script_or_arg' \ '*::script argument: _normal' && return =20 -if [[ "$state" =3D modules ]]; then - local -a modules - modules=3D( - ${${=3D${(f)"$(_call_program modules $words[1] -c \ - 'from\ pydoc\ import\ help\;\ = help\(\"modules\"\)')"}[2,-3]}:#\(package\)} - ) - _wanted modules expl module compadd -a modules && return -fi +case "$state" in + modules) + local -a modules + modules=3D( + ${${=3D${(f)"$(_call_program modules $words[1] -c \ + 'from\ pydoc\ import\ help\;\ = help\(\"modules\"\)')"}[2,-3]}:#\(package\)} + ) + _wanted modules expl module compadd -a modules && return + ;; + script_or_arg) + if [[ -n "$opt_args[(I)-(c|m)]" ]]; then + _description arg expl 'file' + _files "$expl[@]" && return + else + _description script expl 'Python script' + _files "$expl[@]" -g "*.py(|c|o)(-.)" && return + fi + ;; +esac =20 return 1 diff --git a/Completion/Unix/Command/_ruby = b/Completion/Unix/Command/_ruby index 03f4e60..80f92d5 100644 --- a/Completion/Unix/Command/_ruby +++ b/Completion/Unix/Command/_ruby @@ -8,7 +8,7 @@ typeset -A opt_args local -a args opts =20 args=3D( - '(-)1:script file:_files' + '(-)1:script or argument:->script_or_arg' '*::script argument: _normal' ) =20 @@ -18,7 +18,7 @@ opts=3D( '-c[check syntax only]' '-C+[cd to directory, before executing your script]:directory:_files = -/' '(-d --debug)'{-d,--debug}'[set debugging flags (set $DEBUG to = true)]' - "(1)*-e+[one line of script (several -e's allowed, omit program = file)]:one line of script:" + "*-e+[one line of script (several -e's allowed, omit program = file)]:one line of script:" '-F-[split() pattern for autosplit (-a)]:input field separator:' '-i-[edit ARGV files in place (make backup if extension = supplied)]:suffix for in-place-edit mode:(.bak)' '*-I+[specify $LOAD_PATH directory (may be used more than = once)]:library directory:_files -/' @@ -67,6 +67,16 @@ case "$state" in dirs=3D( $(_call_program directories $cmd -e 'puts\ \$:' = 2>/dev/null) ${(s.:.)opt_args[-I]} ) _wanted libraries expl library _path_files -W dirs && ret=3D0 ;; + script_or_arg) + if [[ -n "$opt_args[(I)-e]" ]]; then + _description arg expl 'file' + _files "$expl[@]" && ret=3D0 + else + _description script expl 'Ruby script' + _files "$expl[@]" && ret=3D0 + #_files "$expl[@]" -g "*.rb(-.)" && ret=3D0 + fi + ;; esac =20 return ret