zsh-workers
 help / color / mirror / code / Atom feed
* A strange quoted nested evaluation issue
@ 2018-11-19  8:04 Ian F
  2018-11-19 18:39 ` dana
  0 siblings, 1 reply; 3+ messages in thread
From: Ian F @ 2018-11-19  8:04 UTC (permalink / raw)
  To: zsh-workers

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

Hi,

Can anyone shed some light On This One?

tl;dr: Enclosing a nested length eval on an empty var changes its answer
from 0 to 1 when in double quotes.

% for baz in "" "inga"; do
echo ${#${baz}} "${#${baz}}" ${#baz} "${#baz}"
done
0 1 0 0
4 4 4 4
%

Normally I wouldn't mail the list about this kind of thing, but this one's
just too weird.  Thoughts?

%Ian

-
Ian F
plus one, seven oh seven, seven three seven, four twenty-one zero.

Big hitter, the Lama.

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

* Re: A strange quoted nested evaluation issue
  2018-11-19  8:04 A strange quoted nested evaluation issue Ian F
@ 2018-11-19 18:39 ` dana
  2018-11-20 14:26   ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: dana @ 2018-11-19 18:39 UTC (permalink / raw)
  To: Ian F; +Cc: zsh-workers

On 19 Nov 2018, at 02:04, Ian F <in4mer@gmail.com> wrote:
>Normally I wouldn't mail the list about this kind of thing, but this one's
>just too weird.  Thoughts?

It's counting a Nularg (0xa1). And it's not just a problem there; try e.g.
"${(g<>)${baz}}" or "${(l<3><x>)${baz}}". Not sure where the best place to fix
it is though

dana


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

* Re: A strange quoted nested evaluation issue
  2018-11-19 18:39 ` dana
@ 2018-11-20 14:26   ` Peter Stephenson
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2018-11-20 14:26 UTC (permalink / raw)
  To: zsh-workers

On Mon, 2018-11-19 at 12:39 -0600, dana wrote:
> On 19 Nov 2018, at 02:04, Ian F <in4mer@gmail.com> wrote:
> > 
> > Normally I wouldn't mail the list about this kind of thing, but this one's
> > just too weird.  Thoughts?
> It's counting a Nularg (0xa1). And it's not just a problem there; try e.g.
> "${(g<>)${baz}}" or "${(l<3><x>)${baz}}". Not sure where the best place to fix
> it is though

Right.

This, I think.

pws

diff --git a/Src/subst.c b/Src/subst.c
index c706b96..ff6750a 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2405,6 +2405,8 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
 	    aspar = 0;
 	} else if (aspar)
 	    idbeg = val;
+	if (*val == Nularg)
+	    ++val;
 	*s = sav;
 	/*
 	 * This tests for the second double quote in an expression


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

end of thread, other threads:[~2018-11-20 14:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-19  8:04 A strange quoted nested evaluation issue Ian F
2018-11-19 18:39 ` dana
2018-11-20 14:26   ` Peter Stephenson

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