* Re: PATCH: _next_label losing empty arguments
@ 2000-05-23 8:51 Sven Wischnowsky
0 siblings, 0 replies; 3+ messages in thread
From: Sven Wischnowsky @ 2000-05-23 8:51 UTC (permalink / raw)
To: zsh-workers
Oliver Kiddle wrote:
> Firstly, thanks Bart for the _arguments fix - that solved my problem.
Yes, thanks, Bart. My fault...
> ...
>
> Is the use of set in this patch instead of eval safe? [...]
Blink. I had completely forgotten about `set -A'. Cute. Faster and
much more readable. Let's use it in other places, too.
(Oliver, I also changed your changes to use ${(@)argv[...]} instead of
${argv[...][@]}, mostly for consistency with other places, but I think
it should also be a tad faster. Haven't measured that, though.)
Bye
Sven
Index: Completion/Base/_arguments
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/_arguments,v
retrieving revision 1.21
diff -u -r1.21 _arguments
--- Completion/Base/_arguments 2000/05/22 17:18:05 1.21
+++ Completion/Base/_arguments 2000/05/23 08:51:40
@@ -149,7 +149,7 @@
cache=( "$cache[@]" "$tmp[@]" )
fi
done
- eval "${name}=( \"\${(@)cache:# #}\" )"
+ set -A "$name" "${(@)cache:# #}"
fi
set -- "$tmpargv[@]" "${(@P)name}"
fi
Index: Completion/Commands/_complete_help
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Commands/_complete_help,v
retrieving revision 1.7
diff -u -r1.7 _complete_help
--- Completion/Commands/_complete_help 2000/05/10 04:55:10 1.7
+++ Completion/Commands/_complete_help 2000/05/23 08:51:41
@@ -32,7 +32,7 @@
# No need to call the completers more than once with different match specs.
if [[ "$3" = matcher-list ]]; then
- eval "${4}=( '' )"
+ set -A "$4" ''
else
builtin zstyle "$@"
fi
Index: Completion/Commands/_next_tags
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Commands/_next_tags,v
retrieving revision 1.5
diff -u -r1.5 _next_tags
--- Completion/Commands/_next_tags 2000/04/11 07:57:56 1.5
+++ Completion/Commands/_next_tags 2000/05/23 08:51:41
@@ -62,10 +62,10 @@
zformat -f descr "${curtag#*:}" "d:$3"
_description "$gopt" "${curtag%:*}" "$2" "$descr"
curtag="${curtag%:*}"
- eval "${2}=( \${(P)2} \$argv[4,-1] )"
+ set -A "$2" "${(P@)2}" "${(@)argv[4,-1]}"
else
_description "$gopt" "$curtag" "$2" "$3"
- eval "${2}=( \$argv[4,-1] \${(P)2} )"
+ set -A "$2" "${(@)argv[4,-1]}" "${(P@)2}"
fi
return 0
Index: Completion/Core/_description
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_description,v
retrieving revision 1.5
diff -u -r1.5 _description
--- Completion/Core/_description 2000/05/15 23:33:30 1.5
+++ Completion/Core/_description 2000/05/23 08:51:41
@@ -26,8 +26,8 @@
zstyle -s ":completion:${curcontext}:$1" group-name gname &&
[[ -z "$gname" ]] && gname="$1"
zstyle -s ":completion:${curcontext}:$1" matcher match &&
- opts=($opts -M "${(q)match}")
-[[ -n "$_matcher" ]] && opts=($opts -M "${(q)_matcher}")
+ opts=($opts -M "$match")
+[[ -n "$_matcher" ]] && opts=($opts -M "$_matcher")
if [[ -z "$_comp_no_ignore" ]]; then
if zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore; then
@@ -48,15 +48,15 @@
if [[ -n "$gname" ]]; then
if [[ -n "$format" ]]; then
- eval "${name}=($opts $gropt ${(q)gname} -X \"${format}\")"
+ set -A "$name" "$opts[@]" "$gropt" "$gname" -X "$format"
else
- eval "${name}=($opts $gropt ${(q)gname})"
+ set -A "$name" "$opts[@]" "$gropt" "$gname"
fi
else
if [[ -n "$format" ]]; then
- eval "${name}=($opts $gropt -default- -X \"${format}\")"
+ set -A "$name" "$opts[@]" "$gropt" -default- -X "$format"
else
- eval "${name}=($opts $gropt -default-)"
+ set -A "$name" "$opts[@]" "$gropt" -default-
fi
fi
Index: Completion/Core/_next_label
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_next_label,v
retrieving revision 1.3
diff -u -r1.3 _next_label
--- Completion/Core/_next_label 2000/05/22 18:15:54 1.3
+++ Completion/Core/_next_label 2000/05/23 08:51:41
@@ -13,10 +13,10 @@
zformat -f descr "${curtag#*:}" "d:$3"
_description "$gopt" "${curtag%:*}" "$2" "$descr"
curtag="${curtag%:*}"
- set -A $2 "${(P@)2}" "${argv[4,-1][@]}"
+ set -A $2 "${(P@)2}" "${(@)argv[4,-1]}"
else
_description "$gopt" "$curtag" "$2" "$3"
- set -A $2 "${argv[4,-1][@]}" "${(P@)2}"
+ set -A $2 "${(@)argv[4,-1]}" "${(P@)2}"
fi
return 0
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: _next_label losing empty arguments
2000-05-22 18:12 Oliver Kiddle
@ 2000-05-22 18:33 ` Bart Schaefer
0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2000-05-22 18:33 UTC (permalink / raw)
To: Zsh workers
On May 22, 7:12pm, Oliver Kiddle wrote:
> Subject: PATCH: _next_label losing empty arguments
>
> > set -A a - 1 2 3
> > echo $#a
> 4
> > echo $a[1]
>
> Surely, a[1] should not be empty: it should either be '-' or ...
It *is* '-'.
What do you get from `echo -` ?
^ permalink raw reply [flat|nested] 3+ messages in thread
* PATCH: _next_label losing empty arguments
@ 2000-05-22 18:12 Oliver Kiddle
2000-05-22 18:33 ` Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2000-05-22 18:12 UTC (permalink / raw)
To: Zsh workers
Firstly, thanks Bart for the _arguments fix - that solved my problem.
I was just looking at putting the "$@"s back in to _urls on the
_next_label lines and things were not working as I hoped. The problem
occurred where I used a -S '' because _next_labels was losing the ''
argument when sticking them in the expl array.
Is the use of set in this patch instead of eval safe? I tried to answer
this myself and the following behaviour doesn't seem right:
> set -A a - 1 2 3
> echo $#a
4
> echo $a[1]
Surely, a[1] should not be empty: it should either be '-' or we should
use the ksh behaviour (the array would contain just 1,2 and 3).
Oliver
Index: Completion/Core/_next_label
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_next_label,v
retrieving revision 1.2
diff -u -r1.2 _next_label
--- Completion/Core/_next_label 2000/04/11 07:57:57 1.2
+++ Completion/Core/_next_label 2000/05/22 18:11:31
@@ -13,10 +13,10 @@
zformat -f descr "${curtag#*:}" "d:$3"
_description "$gopt" "${curtag%:*}" "$2" "$descr"
curtag="${curtag%:*}"
- eval "${2}=( \${(P)2} \$argv[4,-1] )"
+ set -A $2 "${(P@)2}" "${argv[4,-1][@]}"
else
_description "$gopt" "$curtag" "$2" "$3"
- eval "${2}=( \$argv[4,-1] \${(P)2} )"
+ set -A $2 "${argv[4,-1][@]}" "${(P@)2}"
fi
return 0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2000-05-23 8:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-23 8:51 PATCH: _next_label losing empty arguments Sven Wischnowsky
-- strict thread matches above, loose matches on Subject: below --
2000-05-22 18:12 Oliver Kiddle
2000-05-22 18:33 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).