zsh-workers
 help / color / mirror / code / Atom feed
* Recent regression on (N) after removing array element
@ 2013-11-19 17:08 Vin Shelton
  2013-11-19 17:52 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Vin Shelton @ 2013-11-19 17:08 UTC (permalink / raw)
  To: zsh-workers

This used to work:

x=( /bin /foo )
x[(r)/foo]=''
x=( $^x(N) )

but the last line now yields an error:
zsh: no matches found: (N)

If I remove this recent change to Src/glob.c, (N) works correctly:

--- /opt/src/zsh-2013-11-17/Src/glob.c 2013-09-23 18:01:42.000000000 -0400
+++ /opt/src/zsh-2013-11-19/Src/glob.c 2013-11-19 10:22:39.000000000 -0500
@@ -1171,7 +1171,7 @@
  break;
     }
  }
- if (*s != Inpar)
+ if (*s != Inpar || s == str)
     break;
  if (isset(EXTENDEDGLOB) && !zpc_disables[ZPC_HASH] && s[1] == Pound) {
     if (s[2] == 'q') {


Sincerely,
  Vin


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

* Re: Recent regression on (N) after removing array element
  2013-11-19 17:08 Recent regression on (N) after removing array element Vin Shelton
@ 2013-11-19 17:52 ` Peter Stephenson
  2013-11-19 18:02   ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2013-11-19 17:52 UTC (permalink / raw)
  To: zsh-workers

On Tue, 19 Nov 2013 12:08:04 -0500
Vin Shelton <acs@alumni.princeton.edu> wrote:
> This used to work:
> 
> x=( /bin /foo )
> x[(r)/foo]=''
> x=( $^x(N) )
> 
> but the last line now yields an error:
> zsh: no matches found: (N)
> 
> If I remove this recent change to Src/glob.c, (N) works correctly:

What we didn't think of was glob qualifiers that transformed a failed
match in some way.  Although the empty string isn't a valid file name,
it is a valid failed match for a file name.

It's quite hard to see how to improve the test so that we can still
check for something before the (N).  By the time globbing comes along,
it's already been expanded to a bare (N), so we can't see that the user
originally had something in front.

Apart from going back to the original, the only ways round that occur to
me involve reparsing on failure, e.g. reinterpreting as glob qualifiers
if no matches were found.  But that's probably worse than the original
disease.

pws


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

* Re: Recent regression on (N) after removing array element
  2013-11-19 17:52 ` Peter Stephenson
@ 2013-11-19 18:02   ` Bart Schaefer
  2013-11-20 17:33     ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2013-11-19 18:02 UTC (permalink / raw)
  To: zsh-workers

On Nov 19,  5:52pm, Peter Stephenson wrote:
}
} What we didn't think of was glob qualifiers that transformed a failed
} match in some way.  Although the empty string isn't a valid file name,
} it is a valid failed match for a file name.

I was hoping there might be some way we can distinguish, e.g., that a
null token appears there rather than an empty string, but apparently
those are stripped by the time we reach globbing.
 
} Apart from going back to the original, the only ways round that occur to
} me involve reparsing on failure, e.g. reinterpreting as glob qualifiers
} if no matches were found.  But that's probably worse than the original
} disease.

Yeah, I think we have to back this one out.


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

* Re: Recent regression on (N) after removing array element
  2013-11-19 18:02   ` Bart Schaefer
@ 2013-11-20 17:33     ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2013-11-20 17:33 UTC (permalink / raw)
  To: zsh-workers

On Tue, 19 Nov 2013 10:02:22 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> } Apart from going back to the original, the only ways round that occur to
> } me involve reparsing on failure, e.g. reinterpreting as glob qualifiers
> } if no matches were found.  But that's probably worse than the original
> } disease.
> 
> Yeah, I think we have to back this one out.

In the absence of immediate smart ideas...

Here's a test so we don't forget.

diff --git a/Src/glob.c b/Src/glob.c
index 385b9e6..e0d0cf6 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -1171,7 +1171,7 @@ zglob(LinkList list, LinkNode np, int nountok)
 		break;
 	    }
 	}
-	if (*s != Inpar || s == str)
+	if (*s != Inpar)
 	    break;
 	if (isset(EXTENDEDGLOB) && !zpc_disables[ZPC_HASH] && s[1] == Pound) {
 	    if (s[2] == 'q') {
diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst
index d6ab733..81b0021 100644
--- a/Test/D02glob.ztst
+++ b/Test/D02glob.ztst
@@ -491,3 +491,11 @@
 >@(scrimf), @(scrimf): 0
 >'(' '*' '[' '^' '@('
 >Nothing should be disabled.
+
+  (
+   setopt nomatch
+   x=( '' )
+   print $^x(N)
+  )
+0:No error with empty null glob with (N).
+>

pws


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

end of thread, other threads:[~2013-11-20 17:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-19 17:08 Recent regression on (N) after removing array element Vin Shelton
2013-11-19 17:52 ` Peter Stephenson
2013-11-19 18:02   ` Bart Schaefer
2013-11-20 17:33     ` 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).