* PATCH: small parameter fix
@ 1999-03-08 8:50 Sven Wischnowsky
1999-03-08 9:01 ` Bart Schaefer
0 siblings, 1 reply; 7+ messages in thread
From: Sven Wischnowsky @ 1999-03-08 8:50 UTC (permalink / raw)
To: zsh-workers
...although I'm not sure if it was not intentional. If it was, I'd
like to hear the reason. This:
${${...}[...]}
previously didn't really work: if the inner ${...} produced an array
with only one element, the outer ${...} treated it as a string and the
subscript gave the n'th character.
Bye
Sven
--- os/subst.c Fri Mar 5 20:10:39 1999
+++ Src/subst.c Sat Mar 6 13:28:41 1999
@@ -263,7 +263,7 @@
*isarr = 0;
return 0;
}
- if ((l = countlinknodes(foo)) > 1) {
+ if ((l = countlinknodes(foo)) > 1 || a) {
p = r = ncalloc((l + 1) * sizeof(char*));
while (nonempty(foo))
*p++ = (char *)ugetnode(foo);
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PATCH: small parameter fix
1999-03-08 8:50 PATCH: small parameter fix Sven Wischnowsky
@ 1999-03-08 9:01 ` Bart Schaefer
1999-03-08 15:55 ` Peter Stephenson
0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 1999-03-08 9:01 UTC (permalink / raw)
To: Sven Wischnowsky; +Cc: zsh-workers
Sven Wischnowsky writes:
>
> ...although I'm not sure if it was not intentional. If it was, I'd
> like to hear the reason. This:
>
> ${${...}[...]}
>
> previously didn't really work: if the inner ${...} produced an array
> with only one element, the outer ${...} treated it as a string and the
> subscript gave the n'th character.
AHA! This must be the reason that "${${(@)...}...}" is required in so
many mystifying circumstances. I, too, would like to hear whether the
previous behavior was intentional ... this change does potentially
break scripts, including I think 3.0.5 scripts, so we'd better tread
carefully.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PATCH: small parameter fix
1999-03-08 9:01 ` Bart Schaefer
@ 1999-03-08 15:55 ` Peter Stephenson
1999-03-09 8:16 ` Andrej Borsenkow
0 siblings, 1 reply; 7+ messages in thread
From: Peter Stephenson @ 1999-03-08 15:55 UTC (permalink / raw)
To: Zsh hackers list
> >
> > ${${...}[...]}
> >
> > previously didn't really work: if the inner ${...} produced an array
> > with only one element, the outer ${...} treated it as a string and the
> > subscript gave the n'th character.
>
> AHA! This must be the reason that "${${(@)...}...}" is required in so
> many mystifying circumstances. I, too, would like to hear whether the
> previous behavior was intentional ... this change does potentially
> break scripts, including I think 3.0.5 scripts, so we'd better tread
> carefully.
in particular it has this effect:
% print "${$(uname -n)[1]}"
ibmth
where you might guess $(...) in quotes produced a scalar for subscripting
--- indeed it did, but the subscripting decided to treat it as an array
element. In fact, since the nested substitution recognises the quotes
whereas the subscripting doesn't, you get,
% print "${${path}[1]}"
/home/user2/pws/bin /home/user2/pws/links /home/user2/pws/mh/bin
/home/user2/pws/scripts /usr/local/bin /usr/sue/bin /usr/bin /usr/bin/X11
/usr/ucb /usr/local/bin/X11 /cern/pro/bin /usr/local/cap /etc .
(wrapped a bit --- well, you don't get that, but I do) which is distinctly
on the strange side. I would suggest that in quotes the old behaviour
character-subscripting behaviour is the right one.
--
Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: PATCH: small parameter fix
1999-03-08 15:55 ` Peter Stephenson
@ 1999-03-09 8:16 ` Andrej Borsenkow
0 siblings, 0 replies; 7+ messages in thread
From: Andrej Borsenkow @ 1999-03-09 8:16 UTC (permalink / raw)
To: Peter Stephenson, Zsh hackers list
I would suggest that in quotes the old behaviour
> character-subscripting behaviour is the right one.
>
And consistent with manuals. By definition, "...${array}..." gives a scalar
*unless* ``@'' is used
/andrej
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PATCH: small parameter fix
@ 1999-03-09 10:30 Sven Wischnowsky
0 siblings, 0 replies; 7+ messages in thread
From: Sven Wischnowsky @ 1999-03-09 10:30 UTC (permalink / raw)
To: zsh-workers
I wrote:
> The patch at least fixes this. But maybe we should collect opinions
> which expression should expand to what and then make the code produce
> that.
And here is the patch that makes `_long_options' and `_multi_parts'
use this...
Bye
Sven
--- oc/User/_long_options Tue Mar 9 09:05:06 1999
+++ Completion/User/_long_options Tue Mar 9 11:03:08 1999
@@ -87,9 +87,9 @@
# option up to the end. Finally all elements with option strings
# that contain uppercase letters are removed.
- opts=("--${^${${${(M)${(@ps:\n:j:\n:)${(@)${(M)${(@f)$($words[1] --help)}:#[ ]#-*}//,/
+ opts=("--${(@)^${(@)${(@)${(@M)${(@ps:\n:j:\n:)${(@)${(@M)${(@f)$("$words[1]" --help)}:#[ ]#-*}//,/
}}:#*--*}#*--}%%[, ]*}:#(*-[A-Z]*|)}")
-
+echo $#opts
# The interpretation of the options is completely table driven. We
# use the positional parameters we were given and a few standard
# ones. Then we loop through this table.
@@ -144,7 +144,7 @@
# an array.
tmp=("${(@)tmp:#*\[\=*}")
- tmpo=("${${(@)tmpo%%\=*}//[^a-z0-9-]}")
+ tmpo=("${(@)${(@)tmpo%%\=*}//[^a-z0-9-]}")
_lo_cache_actions[anum]="_lo_cache_optarg_$anum $action"
eval "_lo_cache_optarg_${anum}=(\"\$tmpo[@]\")"
(( anum++ ))
@@ -156,7 +156,7 @@
tmpo=("${(@M)tmp:#*\=*}")
if (( $#tmpo )); then
tmp=("${(@)tmp:#*\=*}")
- tmpo=("${${(@)tmpo%%\=*}//[^a-z0-9-]}")
+ tmpo=("${(@)${(@)tmpo%%\=*}//[^a-z0-9-]}")
_lo_cache_actions[anum]="_lo_cache_arg_$anum $action"
eval "_lo_cache_arg_${anum}=(\"\$tmpo[@]\")"
(( anum++ ))
@@ -169,7 +169,7 @@
# Now filter out any option strings we don't like and stuff them
# in an array, if there are still some.
- tmp=("${${(@)tmp%%\=*}//[^a-z0-9-]}")
+ tmp=("${(@)${(@)tmp%%\=*}//[^a-z0-9-]}")
if (( $#tmp )); then
_lo_cache_actions[anum]="$name $action"
eval "${name}=(\"\$tmp[@]\")"
@@ -215,7 +215,7 @@
for i in "$_lo_cache_actions[@]"; do
name="${i%% *}"
action="${i#* }"
- if (( ${${(@P)name}[(I)$pre]} )); then
+ if (( ${(@)${(@P)name}[(I)$pre]} )); then
if [[ "$action[1]" = (\[|\() ]]; then
compadd - ${=action[2,-2]}
elif (( $#action )); then
diff -u oc/Core/_multi_parts Completion/Core/_multi_parts
--- oc/Core/_multi_parts Mon Mar 8 11:05:13 1999
+++ Completion/Core/_multi_parts Tue Mar 9 10:21:02 1999
@@ -85,7 +85,7 @@
tmp1="${orig%%${sep}*}${sep}"
pref="$pref$tmp1"
- matches=("${${(@)${(@M)matches:#${tmp1}*}#$tmp1}:#}")
+ matches=("${(@)${(@)${(@M)matches:#${tmp1}*}#$tmp1}:#}")
orig="${orig#*${sep}}"
patstr="${patstr#*${sep}}"
done
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PATCH: small parameter fix
@ 1999-03-09 10:12 Sven Wischnowsky
0 siblings, 0 replies; 7+ messages in thread
From: Sven Wischnowsky @ 1999-03-09 10:12 UTC (permalink / raw)
To: zsh-workers
I wrote:
> With the patch below we get:
>
> % echo ${$(uname -n)[1]}
> beta
> % echo "${$(uname -n)[1]}"
> b
> % echo ${${path}[1]}
> /users/wischnow/bin/alpha
> % echo "${${path}[1]}"
> /
>
> ...which seems sensible to me.
Grrr, this broke "${(@)$(foo)#...}" where the manual says that the
thing inside will be treated as an array if the `(@)' flags is given.
The patch at least fixes this. But maybe we should collect opinions
which expression should expand to what and then make the code produce
that.
Bye
Sven
--- os/subst.c Tue Mar 9 11:07:25 1999
+++ Src/subst.c Tue Mar 9 11:10:13 1999
@@ -976,7 +976,8 @@
skipparens(*s, *s == Inpar ? Outpar : Outbrace, &s);
sav = *s;
*s = 0;
- if (multsub(&val, ((quoted || aspar) ? NULL : &aval), &isarr, NULL) &&
+ if (multsub(&val, (((quoted || aspar) && !nojoin) ? NULL : &aval),
+ &isarr, NULL) &&
quoted) {
isarr = -1;
aval = alloc(sizeof(char *));
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PATCH: small parameter fix
@ 1999-03-09 8:19 Sven Wischnowsky
0 siblings, 0 replies; 7+ messages in thread
From: Sven Wischnowsky @ 1999-03-09 8:19 UTC (permalink / raw)
To: zsh-workers
Peter Stephenson wrote:
> in particular it has this effect:
>
> % print "${$(uname -n)[1]}"
> ibmth
>
> where you might guess $(...) in quotes produced a scalar for subscripting
> --- indeed it did, but the subscripting decided to treat it as an array
> element. In fact, since the nested substitution recognises the quotes
> whereas the subscripting doesn't, you get,
>
> % print "${${path}[1]}"
> /home/user2/pws/bin /home/user2/pws/links /home/user2/pws/mh/bin
> /home/user2/pws/scripts /usr/local/bin /usr/sue/bin /usr/bin /usr/bin/X11
> /usr/ucb /usr/local/bin/X11 /cern/pro/bin /usr/local/cap /etc .
>
> (wrapped a bit --- well, you don't get that, but I do) which is distinctly
> on the strange side. I would suggest that in quotes the old behaviour
> character-subscripting behaviour is the right one.
With the patch below we get:
% echo ${$(uname -n)[1]}
beta
% echo "${$(uname -n)[1]}"
b
% echo ${${path}[1]}
/users/wischnow/bin/alpha
% echo "${${path}[1]}"
/
...which seems sensible to me.
Bye
Sven
--- os/subst.c Mon Mar 8 09:51:27 1999
+++ Src/subst.c Tue Mar 9 09:16:13 1999
@@ -976,7 +976,8 @@
skipparens(*s, *s == Inpar ? Outpar : Outbrace, &s);
sav = *s;
*s = 0;
- if (multsub(&val, (aspar ? NULL : &aval), &isarr, NULL) && quoted) {
+ if (multsub(&val, ((quoted || aspar) ? NULL : &aval), &isarr, NULL) &&
+ quoted) {
isarr = -1;
aval = alloc(sizeof(char *));
aspar = 0;
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~1999-03-09 10:31 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-08 8:50 PATCH: small parameter fix Sven Wischnowsky
1999-03-08 9:01 ` Bart Schaefer
1999-03-08 15:55 ` Peter Stephenson
1999-03-09 8:16 ` Andrej Borsenkow
1999-03-09 8:19 Sven Wischnowsky
1999-03-09 10:12 Sven Wischnowsky
1999-03-09 10:30 Sven Wischnowsky
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).