* extendedglob recursion (/)#
@ 2015-02-26 0:51 Eric Cook
2015-02-26 3:22 ` Eric Cook
2015-02-26 4:56 ` Bart Schaefer
0 siblings, 2 replies; 4+ messages in thread
From: Eric Cook @ 2015-02-26 0:51 UTC (permalink / raw)
To: zsh-workers
Playing around in IRC with the command:
setopt extendedglob; print (/)# # or /usr/(/)#, etc.
zsh starts to recurse / repeatedly and eventually(errors and) prints /
// ///...
Mikachu | % pl (/)#|wc -l
Mikachu | glob.c:276: BUG: statfullpath(): pathname too long
What should the 'proper' behavior be? Recursing into directories below /
or just printing `/'
I am in favor of the latter personally.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: extendedglob recursion (/)#
2015-02-26 0:51 extendedglob recursion (/)# Eric Cook
@ 2015-02-26 3:22 ` Eric Cook
2015-02-26 4:56 ` Bart Schaefer
1 sibling, 0 replies; 4+ messages in thread
From: Eric Cook @ 2015-02-26 3:22 UTC (permalink / raw)
To: zsh-workers
On 02/25/2015 07:51 PM, Eric Cook wrote:
> Playing around in IRC with the command:
> setopt extendedglob; print (/)# # or /usr/(/)#, etc.
>
> zsh starts to recurse / repeatedly and eventually(errors and) prints /
> // ///...
>
> Mikachu | % pl (/)#|wc -l
> Mikachu | glob.c:276: BUG: statfullpath(): pathname too long
>
> What should the 'proper' behavior be? Recursing into directories below /
> or just printing `/'
> I am in favor of the latter personally.
>
>
On second thought, recursing into the directories below /wouldn't make
much sense with that pattern.
So nevermind about the question, just a bug report.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: extendedglob recursion (/)#
2015-02-26 0:51 extendedglob recursion (/)# Eric Cook
2015-02-26 3:22 ` Eric Cook
@ 2015-02-26 4:56 ` Bart Schaefer
2015-02-26 16:52 ` Bart Schaefer
1 sibling, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2015-02-26 4:56 UTC (permalink / raw)
To: Zsh hackers list
(Apologies if this ends up appearing multiple times. Outgoing mail
from my home machine has mysteriously stopped working [I blame
Verizon] so I'm pasting the message into gmail while I figure out what
the heck is going on.)
On Feb 25, 7:51pm, Eric Cook wrote:
}
} Mikachu | % pl (/)#|wc -l
} Mikachu | glob.c:276: BUG: statfullpath(): pathname too long
}
} What should the 'proper' behavior be? Recursing into directories below /
} or just printing `/'
Recursing into directories below / would definitely be wrong (and would
in any case need to fail with "no match" because there can only be the
one directory named "/").
There's a pretty straightforward fix:
diff --git a/Src/glob.c b/Src/glob.c
index 82f8d62..f48cb8e 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -708,7 +708,8 @@ parsecomplist(char *instr)
}
l1 = (Complist) zhalloc(sizeof *l1);
l1->pat = p1;
- l1->closure = 1 + pdflag;
+ /* special case (/)# to avoid infinite recursion */
+ l1->closure = (p1->patmlen > 0) ? 1 + pdflag : 0;
l1->follow = 0;
l1->next = parsecomplist(instr);
return (l1->pat) ? l1 : NULL;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: extendedglob recursion (/)#
2015-02-26 4:56 ` Bart Schaefer
@ 2015-02-26 16:52 ` Bart Schaefer
0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2015-02-26 16:52 UTC (permalink / raw)
To: Zsh hackers list
On Feb 25, 8:56pm, Bart Schaefer wrote:
}
} + /* special case (/)# to avoid infinite recursion */
} + l1->closure = (p1->patmlen > 0) ? 1 + pdflag : 0;
Sorry, that's not correct. patmlen can be zero in cases other than (/).
diff --git a/Src/glob.c b/Src/glob.c
index 82f8d62..33facde 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -708,7 +708,8 @@ parsecomplist(char *instr)
}
l1 = (Complist) zhalloc(sizeof *l1);
l1->pat = p1;
- l1->closure = 1 + pdflag;
+ /* special case (/)# to avoid infinite recursion */
+ l1->closure = (*((char *)p1 + p1->startoff)) ? 1 + pdflag : 0;
l1->follow = 0;
l1->next = parsecomplist(instr);
return (l1->pat) ? l1 : NULL;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-02-26 16:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-26 0:51 extendedglob recursion (/)# Eric Cook
2015-02-26 3:22 ` Eric Cook
2015-02-26 4:56 ` Bart Schaefer
2015-02-26 16:52 ` Bart Schaefer
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).