zsh-workers
 help / color / mirror / code / Atom feed
* Possible bug with parameter expansion
@ 2001-03-07 11:36 Oliver Kiddle
  2001-03-08 16:33 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2001-03-07 11:36 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: param --]
[-- Type: text/plain, Size: 397 bytes --]

The ${name:#pattern} form of parameter expansion doesn't work within
double quotes. It is acting as if the pattern matched all the elements.
The following should demonstrate:

% a=( a d=rt b=fg c e=yt )
% echo ${a:#*=*}
a c
% echo "${a:#*=*}"

% echo "${(M)a:#*=*}"
a d=rt b=fg c e=yt

This looks like a bug to me because I can't see why the double quotes
should be affecting the result.

Oliver


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Possible bug with parameter expansion
  2001-03-07 11:36 Possible bug with parameter expansion Oliver Kiddle
@ 2001-03-08 16:33 ` Bart Schaefer
  2001-03-12 13:13   ` Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2001-03-08 16:33 UTC (permalink / raw)
  To: Oliver Kiddle, zsh-workers

On Mar 7, 11:36am, Oliver Kiddle wrote:
} Subject: Possible bug with parameter expansion
}
} The ${name:#pattern} form of parameter expansion doesn't work within
} double quotes. It is acting as if the pattern matched all the elements.

If you read Peter's 11-step "summary of the rules for substitution" you
will see that (4. *Double-Quoted Joining*) comes before (6. *Modifiers*).

} % echo "${(M)a:#*=*}"
} a d=rt b=fg c e=yt

zagzig% echo "${(@M)a:#*=*}" 
d=rt b=fg e=yt

} This looks like a bug to me because I can't see why the double quotes
} should be affecting the result.

Because they do.  I don't recall why joining happens before modifiers,
but I'm pretty sure there was a good reason for it at the time.  Does
this disagree with other shells that support ${var#pat}, e.g. ksh?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Possible bug with parameter expansion
  2001-03-08 16:33 ` Bart Schaefer
@ 2001-03-12 13:13   ` Oliver Kiddle
  0 siblings, 0 replies; 3+ messages in thread
From: Oliver Kiddle @ 2001-03-12 13:13 UTC (permalink / raw)
  To: zsh-workers

On Thu, Mar 08, 2001 at 04:33:15PM +0000, Bart Schaefer wrote:

> If you read Peter's 11-step "summary of the rules for substitution" you
> will see that (4. *Double-Quoted Joining*) comes before (6. *Modifiers*).

fair enough. Thanks.

> Because they do.  I don't recall why joining happens before modifiers,
> but I'm pretty sure there was a good reason for it at the time.  Does
> this disagree with other shells that support ${var#pat}, e.g. ksh?

In ksh, there is no way I know of making var refer to an array because it
expands to the first element of the array and with [@], you get a bad
substitution.

Comparing with bash, I have to use [@] to get an array before the
modifier. With the [@], both bash and zsh work the same regardless of
quotes. So basically, I haven't been able to create a comparable situation
in bash or ksh.

I still think the behaviour seems odd mainly because I'm used to reading
these substitutions from the inside out and the double quotes are on the
outside.

Oliver


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-03-12 13:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-07 11:36 Possible bug with parameter expansion Oliver Kiddle
2001-03-08 16:33 ` Bart Schaefer
2001-03-12 13:13   ` Oliver Kiddle

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).