zsh-workers
 help / color / mirror / code / Atom feed
* Patterns in parameter substitution and quoting weirdness
@ 2000-08-16 12:10 Andrej Borsenkow
  2000-08-16 12:21 ` Andrej Borsenkow
  0 siblings, 1 reply; 2+ messages in thread
From: Andrej Borsenkow @ 2000-08-16 12:10 UTC (permalink / raw)
  To: ZSH workers mailing list

It does not look like they behave very consistently in respect to quoting.
Consider:

bor@itsrm2% typeset -A foo
bor@itsrm2% foo[ab]=ab_val
bor@itsrm2% foo[a\?]=a\?_val
bor@itsrm2% print ${(v)foo[(I)a?]}
ab_val <= where is `a?_val' ?? That looks like a plain bug
bor@itsrm2% print "${(v)foo[(I)a?]}"
ab_val <= so, `?' is not quoted by "..." ... but
bor@itsrm2% print ${(v)foo[(I)a\?]}
       <= ... it is quoted by \ or '...'
bor@itsrm2% print "${(v)foo[(I)a\?]}"
       <= I'd like very much to know, what's going on behind ...
bor@itsrm2% print "${(v)foo[(I)a\\?]}"
       <= I'd expect THIS to work - after all, zsh finally see '\?'
bor@itsrm2% print "${(v)foo[(I)a\\\?]}"
a?_val <= and here zsh actually gets '\\?' !

It looks, like string floats around with (de-)quoting applied here and there.

bor@itsrm2% bar='a?b'
bor@itsrm2% print ${bar/a?/ZZ}
ZZb <= that's O.K.
bor@itsrm2% print ${bar/a\?/ZZ}
ZZb <= sorry? While I can understand it, why it differs from the subscript?
bor@itsrm2% print "${bar/a?/ZZ}"
ZZb <= if the above is correct, this is correct as well
bor@itsrm2% print "${bar/a\?/ZZ}"
ZZb <= that is at least strange; see next; and again, why it differs from
subscript?
bor@itsrm2% print "${bar/a\\?/ZZ}"
a?b <= WHAT!? zsh gets exatly the same string as above! (well, well, not
exactly ... but from the user's point of view it is very hard to explain).

As I see it, there are two possibilities:

- consistently apply Zsh quoting rules. That will make literal patterns inside
of double quotes impossible and force usage of temporary parameters.

- use own quoting. The only possibility looks like backslash. But then mention
it in manual at least! :-) And, in this case, it should not matter, if you use
$foo or $~foo for pattern - the result must be the same in both cases.

-andrej

Have a nice DOS!
B >>


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

* RE: Patterns in parameter substitution and quoting weirdness
  2000-08-16 12:10 Patterns in parameter substitution and quoting weirdness Andrej Borsenkow
@ 2000-08-16 12:21 ` Andrej Borsenkow
  0 siblings, 0 replies; 2+ messages in thread
From: Andrej Borsenkow @ 2000-08-16 12:21 UTC (permalink / raw)
  To: ZSH workers mailing list

> bor@itsrm2% foo[a\?]=a\?_val
> bor@itsrm2% print ${(v)foo[(I)a?]}
> bor@itsrm2% print ${(v)foo[(I)a\?]}
>        <= ... it is quoted by \ or '...'

Sorry, the problem is, of course, that I expect it to print `a?_val'.

>
> bor@itsrm2% bar='a?b'
> bor@itsrm2% print ${bar/a\?/ZZ}
> ZZb <= sorry? While I can understand it, why it differs from the subscript?
> bor@itsrm2% print "${bar/a?/ZZ}"
> ZZb <= if the above is correct, this is correct as well


Again, sorry - this is of course correct IF zsh behaves correctly and quotes
`?' and not treats it as glob in both cases. I cannot devise test to check it
currently.

-andrej


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

end of thread, other threads:[~2000-08-16 12:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-16 12:10 Patterns in parameter substitution and quoting weirdness Andrej Borsenkow
2000-08-16 12:21 ` Andrej Borsenkow

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