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

Re: PATCH: small parameter fix



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@xxxxxxxxxxxxxxxxxxxxxxx



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