Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

RE: _call_program (and possibly other hooks) or opt_args quoting prob lem.



> 
> On May 16,  8:32pm, Borsenkow Andrej wrote:
> }
> } _call_program evals its argument(s). It creates very interesting
problem -
> } we want to quote word separator _but_ we do not want to quote
possible
> } parameter expansions ...
> 
> What about this?
> 
> Index: Completion/Base/Utility/_call_program
> ===================================================================
> retrieving revision 1.1.1.1
> diff -c -r1.1.1.1 _call_program
> --- Completion/Base/Utility/_call_program	2001/04/09 20:14:08
1.1.1.1
> +++ Completion/Base/Utility/_call_program	2002/05/17 18:38:04
> @@ -4,7 +4,7 @@
> 
>  if zstyle -s ":completion:${curcontext}:${1}" command tmp; then
>    if [[ "$tmp" = -* ]]; then
> -    eval "$tmp[2,-1]" "$argv[2,-1]"
> +    eval "$tmp[2,-1]" "${(qqq)argv[2,-1]}"
>    else
>      eval "$tmp"
>    fi
> 

It won't work in this form; it needs at least ${(@qqq)... and in other
branch. Still even with the following:

if zstyle -s ":completion:${curcontext}:${1}" command tmp; then
  if [[ "$tmp" = -* ]]; then
    eval "$tmp[2,-1]" "${(qqq)argv[2,-1]}"
  else
    eval "$tmp"
  fi
else
  eval "${(@qqq)argv[2,-1]}"
fi


I get 

+_info:27> info=( _call_program info info -d $PWD/a b ) 
+_info:29> items=+_info:1> _call_program info info -d $PWD/a b --output
-
+_call_program:3> local tmp
+_call_program:5> zstyle -s :completion::complete:info::info command tmp
+_call_program:12> eval "info" "-d" "\$PWD/a b" "--output" "-"

Remember, (qqq) _quotes_ arguments (using different rules but it does
not matter).

Actually I begin to feel that _arguments should eval parameter value
before storing it. Can anybody give example when parameter value as it
appears on command line is useful? 

-andrej



Messages sorted by: Reverse Date, Date, Thread, Author