Re: bash core dumps doing glob pattern on long string

2022-10-11 Thread Dennis Williamson
On Tue, Oct 11, 2022, 3:12 PM Greg Wooledge wrote: > On Tue, Oct 11, 2022 at 12:38:44PM -0700, Koichi Murase wrote: > > As far as I know, glob/extglob > > does not have constructs that cannot be represented by formal regular > > languages so should always be able to be represented by NFAs and thu

Re: bash core dumps doing glob pattern on long string

2022-10-11 Thread Koichi Murase
2022年10月11日(火) 13:12 Greg Wooledge : > On Tue, Oct 11, 2022 at 12:38:44PM -0700, Koichi Murase wrote: > > As far as I know, glob/extglob > > does not have constructs that cannot be represented by formal regular > > languages so should always be able to be represented by NFAs and thus DFAs. > > It's

Re: bash core dumps doing glob pattern on long string

2022-10-11 Thread Greg Wooledge
On Tue, Oct 11, 2022 at 12:38:44PM -0700, Koichi Murase wrote: > As far as I know, glob/extglob > does not have constructs that cannot be represented by formal regular > languages so should always be able to be represented by NFAs and thus DFAs. It's been too many decades since I studied this stuf

Re: bash core dumps doing glob pattern on long string

2022-10-11 Thread Koichi Murase
2022年10月11日(火) 16:22 Martin D Kealey : > However I note that it's not always possible to make a Deterministic FSA > when you have repeatable groups which themselves don't have fixed lengths > (like a+(a|abbba|aabb*aba)b); This is not true. Any non-deterministic finite automaton (NFA) can be transl

Re: bash core dumps doing glob pattern on long string

2022-10-11 Thread Chet Ramey
On 10/11/22 1:26 AM, Phi Debian wrote: On the contrary I see nor reference saying the 'pattern matching for pathname expansion can also be used by extension to any strings, but now I understand it is. The conditional command is explicit about it: "When the == and != operators are used, the

Re: bash core dumps doing glob pattern on long string

2022-10-11 Thread Phi Debian
On Tue, Oct 11, 2022 at 9:02 AM Martin D Kealey wrote: > Broadly I meant translating into a "preferably" Deterministic > (stackless/non-backtracking) Finite State Automaton. > > However I note that it's not always possible to make a Deterministic FSA > when you have repeatable groups which themse

Re: bash core dumps doing glob pattern on long string

2022-10-11 Thread Martin D Kealey
Broadly I meant translating into a "preferably" Deterministic (stackless/non-backtracking) Finite State Automaton. However I note that it's not always possible to make a Deterministic FSA when you have repeatable groups which themselves don't have fixed lengths (like a+(a|abbba|aabb*aba)b); either

Re: bash core dumps doing glob pattern on long string

2022-10-10 Thread Phi Debian
iner ==> infer sorry about typo's

Re: bash core dumps doing glob pattern on long string

2022-10-10 Thread Phi Debian
Hum, may be I was over optimistic regarding alloca(), it seems it core dumps as well :-), i.e never return NULL. I was mentioning alloca() because I use to do my own stacksize check using getrlimit() and getting the max stack size, and measuring the distance between the stack_base and the recursio

Re: bash core dumps doing glob pattern on long string

2022-10-10 Thread Phi Debian
On Tue, Oct 11, 2022 at 7:23 AM Martin D Kealey wrote: > > 4) compile globs into state machines, the same way that regexes get > compiled, so that they can be matched without needing any recursion. > > -Martin > Do you mean the NFA colud trade recursion for malloc()'d backtracking point record?

Re: bash core dumps doing glob pattern on long string

2022-10-10 Thread Phi Debian
On Mon, Oct 10, 2022 at 9:08 PM Chet Ramey wrote: > That's not the point. The point is that shell pattern matching is used in > contexts other than filename globbing, and the shell shouldn't broadly > impose a filename-only restriction on those uses. > > Chet > Ok got it, I was confused because

Re: bash core dumps doing glob pattern on long string

2022-10-10 Thread Martin D Kealey
On Sun, 9 Oct 2022 at 18:07, Phi Debian wrote: > I was looking at a bug on ksh93 that is "core dumps doing glob pattern on > long string" and it happen that bash > suffer the same. > > $ [[ $(printf '%010d' 0) == +(0) ]] > > I see 3 way of fixing this > > 1) [...] string should be limited to

Re: bash core dumps doing glob pattern on long string

2022-10-10 Thread Chet Ramey
On 10/10/22 12:59 PM, Phi Debian wrote: Ok, I agry that PATH_MAX  should not be considered, because not defined every where (OS's) That's not the point. The point is that shell pattern matching is used in contexts other than filename globbing, and the shell shouldn't broadly impose a filename

Re: bash core dumps doing glob pattern on long string

2022-10-10 Thread Phi Debian
Ok, I agry that PATH_MAX should not be considered, because not defined every where (OS's) If you decide a limit let me know I would use the same for ksh93 :) for the time being we core dump :) Cheers.

Re: bash core dumps doing glob pattern on long string

2022-10-10 Thread Chet Ramey
On 10/9/22 4:07 AM, Phi Debian wrote: I was looking at a bug on ksh93 that is "core dumps doing glob pattern on long string" and it happen that bash suffer the same. $ [[ $(printf '%010d' 0) == +(0) ]] I see 3 way of fixing this 1) [[ string == pattern ]] is for glob pattern, so string sh

Re: bash core dumps doing glob pattern on long string

2022-10-09 Thread Phi Debian
@Oğuz A simple look at the core dump will suffice to convince you that the stack has overflowed. As Koichi stated, both ksh and bash do implement de 'simple' recursive approach. My question was only about the strategy that bash would follow, to converge with bash, i.e we can still both core dump,

Re: bash core dumps doing glob pattern on long string

2022-10-09 Thread Koichi Murase
2022年10月9日(日) 18:37 Oğuz : > I'm not familiar with how extended globs are implemented in either shell > but this doesn't look like something that'd involve recursion. For the particular pattern +(0), you might think it is possible to implement it without recursion, but the extglob engine needs to

Re: bash core dumps doing glob pattern on long string

2022-10-09 Thread Oğuz
9 Ekim 2022 Pazar tarihinde Phi Debian yazdı: > > $ [[ $(printf '%010d' 0) == +(0) ]] > > I see 3 way of fixing this > I'm not familiar with how extended globs are implemented in either shell but this doesn't look like something that'd involve recursion. -- Oğuz