Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

A year spent in artificial intelligence is enough to make one believe in God.


devel / comp.unix.shell / Kornshell limit - recursion depth

SubjectAuthor
* Kornshell limit - recursion depthJanis Papanagnou
+- Kornshell limit - recursion depthDavid W. Hodgins
+- Kornshell limit - recursion depthJanis Papanagnou
`* Kornshell limit - recursion depthKaz Kylheku
 `* Kornshell limit - recursion depthJanis Papanagnou
  +* Kornshell limit - recursion depthKenny McCormack
  |`* Kornshell limit - recursion depthJanis Papanagnou
  | `* Kornshell limit - recursion depthKenny McCormack
  |  `* Kornshell limit - recursion depthJanis Papanagnou
  |   `* Kornshell limit - recursion depthJanis Papanagnou
  |    `- Kornshell limit - recursion depthKenny McCormack
  +* Kornshell limit - recursion depthChristian Weisgerber
  |`- Kornshell limit - recursion depthJanis Papanagnou
  +- Kornshell limit - recursion depthKaz Kylheku
  `* Kornshell limit - recursion depthKaz Kylheku
   `- Kornshell limit - recursion depthJanis Papanagnou

1
Kornshell limit - recursion depth

<thsvs4$9o2u$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6724&group=comp.unix.shell#6724

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Kornshell limit - recursion depth
Date: Sun, 9 Oct 2022 01:07:47 +0200
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <thsvs4$9o2u$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 8 Oct 2022 23:07:48 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="ad3fe5b343e905079bb548c59af15d78";
logging-data="319582"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Vhku/Uw6Kj30JE0AfobCw"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:/kpl3H+EgBcRhewb6B0ZvJAR5vQ=
X-Mozilla-News-Host: news://news.eternal-september.org:119
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 8 Oct 2022 23:07 UTC

In Kornshell I wrote a recursive function that (in practice) requires a
maximum recursion depth of about 3000. There's obviously a fixed limit
defined that lies around 1024 (zsh, for example, has a limit of 1000,
it seems); a test program and the error message:

#!/usr/bin/ksh
typeset l=0
function f { print $((++l)) ; f ;}
f

....
1023
1024
1025
....: f[3]: f: line 3: f: recursion too deep

Any good ideas how to handle/circumvent/extend that limit (in ksh)?

N.B.: Rewriting the (8-branch-cascading) algorithm is not an option.

Janis

Re: Kornshell limit - recursion depth

<op.1tqvjqpba3w0dxdave@hodgins.homeip.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6725&group=comp.unix.shell#6725

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: dwhodgins@nomail.afraid.org (David W. Hodgins)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell limit - recursion depth
Date: Sat, 08 Oct 2022 19:58:28 -0400
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <op.1tqvjqpba3w0dxdave@hodgins.homeip.net>
References: <thsvs4$9o2u$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
Injection-Info: reader01.eternal-september.org; posting-host="da93e075f0ec52f4f9e61ac07af0829e";
logging-data="326382"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/LaxCVh25jdrJ2rBYryxHQtbJqaFQA7L4="
User-Agent: Opera Mail/12.16 (Linux)
Cancel-Lock: sha1:DD1oB5aQjAzWuB5xmLuzWJWop0w=
 by: David W. Hodgins - Sat, 8 Oct 2022 23:58 UTC

On Sat, 08 Oct 2022 19:07:47 -0400, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

> In Kornshell I wrote a recursive function that (in practice) requires a
> maximum recursion depth of about 3000. There's obviously a fixed limit
> defined that lies around 1024 (zsh, for example, has a limit of 1000,
> it seems); a test program and the error message:
>
> #!/usr/bin/ksh
> typeset l=0
> function f { print $((++l)) ; f ;}
> f
>
> ...
> 1023
> 1024
> 1025
> ...: f[3]: f: line 3: f: recursion too deep
>
> Any good ideas how to handle/circumvent/extend that limit (in ksh)?

It may be something set in /etc/security/limits.conf

Regards, Dave Hodgins

Re: Kornshell limit - recursion depth

<tht845$d49s$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6726&group=comp.unix.shell#6726

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell limit - recursion depth
Date: Sun, 9 Oct 2022 03:28:37 +0200
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <tht845$d49s$1@dont-email.me>
References: <thsvs4$9o2u$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 9 Oct 2022 01:28:37 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="ad3fe5b343e905079bb548c59af15d78";
logging-data="430396"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19uhBWGNfvAe1s5FLW8srYn"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:LXG6VZRUjGub535iI9e3/DS9q9k=
In-Reply-To: <thsvs4$9o2u$1@dont-email.me>
 by: Janis Papanagnou - Sun, 9 Oct 2022 01:28 UTC

On 09.10.2022 01:07, Janis Papanagnou wrote:
> [ ksh function call recursion depth limit of 1024 ]
>
> Any good ideas how to handle/circumvent/extend that limit (in ksh)?

I fear it's hard-coded, and that there's no way out. :-/

Janis

Re: Kornshell limit - recursion depth

<20221008214924.841@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6727&group=comp.unix.shell#6727

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell limit - recursion depth
Date: Sun, 9 Oct 2022 05:29:06 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <20221008214924.841@kylheku.com>
References: <thsvs4$9o2u$1@dont-email.me>
Injection-Date: Sun, 9 Oct 2022 05:29:06 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="dceb0821f384fa6a9a5ab7b065967b1a";
logging-data="463050"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18MXm/n7L7xYcugfNxFzhCN1U61QCtioNQ="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:6MGCqk8AvJdIhHDAXWvNZyLY024=
 by: Kaz Kylheku - Sun, 9 Oct 2022 05:29 UTC

On 2022-10-08, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> In Kornshell I wrote a recursive function that (in practice) requires a
> maximum recursion depth of about 3000. There's obviously a fixed limit
> defined that lies around 1024 (zsh, for example, has a limit of 1000,
> it seems); a test program and the error message:
>
> #!/usr/bin/ksh
> typeset l=0
> function f { print $((++l)) ; f ;}
> f
>
> ...
> 1023
> 1024
> 1025
> ...: f[3]: f: line 3: f: recursion too deep

Is this diagnostic literally accurate? What would happen if we wrote a
script that contains over 1000 differently named functions that call
each other in a chain? That's not recursion!
>
> Any good ideas how to handle/circumvent/extend that limit (in ksh)?
>
>
> N.B.: Rewriting the (8-branch-cascading) algorithm is not an option.

Is there a particular branch that generates the depth; and is
it a tail call? Or could it be turned into one?

Without changing an algorithm, we may be able to manually convert some
key tail call in it into iteration, while keeping the others recursive.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: Kornshell limit - recursion depth

<thubhv$g0bh$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6728&group=comp.unix.shell#6728

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell limit - recursion depth
Date: Sun, 9 Oct 2022 13:33:18 +0200
Organization: A noiseless patient Spider
Lines: 78
Message-ID: <thubhv$g0bh$1@dont-email.me>
References: <thsvs4$9o2u$1@dont-email.me> <20221008214924.841@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 9 Oct 2022 11:33:19 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="b0bf0a34aa466265c1f32e5613c5340f";
logging-data="524657"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+N+W59rstM5LB7q9XPfZGT"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:7gZIIWqBAyFt/L1Kh42JZsdDE2o=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <20221008214924.841@kylheku.com>
 by: Janis Papanagnou - Sun, 9 Oct 2022 11:33 UTC

On 09.10.2022 07:29, Kaz Kylheku wrote:
> On 2022-10-08, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>> In Kornshell I wrote a recursive function that (in practice) requires a
>> maximum recursion depth of about 3000. There's obviously a fixed limit
>> defined that lies around 1024 (zsh, for example, has a limit of 1000,
>> it seems); a test program and the error message:
>>
>> #!/usr/bin/ksh
>> typeset l=0
>> function f { print $((++l)) ; f ;}
>> f
>>
>> ...
>> 1023
>> 1024
>> 1025
>> ...: f[3]: f: line 3: f: recursion too deep
>
> Is this diagnostic literally accurate?

I omitted the data lines 1..1022 (that contain the respective values)
where I wrote "..." and also the script name where the second "..."
is, and I manually added the the #! line for informational purposes
(where the script had a blank line; I always feed scripts explicitly
to the interpreter, like 'ksh testscript', in case of tests).

> What would happen if we wrote a
> script that contains over 1000 differently named functions that call
> each other in a chain?

I haven't tried. (My guess is it would trigger.) - ...quick test with

function f { print f=$((++ff)) ; g ;}
function g { print g=$((++gg)) ; f ;}
f

....
g=511
f=512
g=512
f=513
rec[4]: f[2]: g: line 3: g: recursion too deep

> That's not recursion!

No direct recursion, but an indirect one. - I think the naming is okay
but we can also call it a call stack limit.

>>
>> Any good ideas how to handle/circumvent/extend that limit (in ksh)?
>>
>>
>> N.B.: Rewriting the (8-branch-cascading) algorithm is not an option.
>
> Is there a particular branch that generates the depth; and is
> it a tail call? Or could it be turned into one?

It's a cascading recursion with eight possible call branches like

function f { c1 && f ; c2 && f ; ... ; c8 && f ;} # c1..c8: conditions

so it's no tail recursion special case and there's no preferred branch.

Frankly, I cannot say whether it could be transformed - I mean without
explicitly organizing the call stack. I've done that with special cases
of a (simple, 2-branch) cascading function (fib; see comp.lang,awk the
post "Yet another obfuscated Awk code", Jan. 2022), but here I am lost.

>
> Without changing an algorithm, we may be able to manually convert some
> key tail call in it into iteration, while keeping the others recursive.

I think I spoke too soon previously about "[not] rewriting the
algorithm"; if it's a hard coded shell limit then there's no other way
[in shell], I suppose.

Janis

Re: Kornshell limit - recursion depth

<thuc5e$2h04i$1@news.xmission.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6729&group=comp.unix.shell#6729

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell limit - recursion depth
Date: Sun, 9 Oct 2022 11:43:42 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <thuc5e$2h04i$1@news.xmission.com>
References: <thsvs4$9o2u$1@dont-email.me> <20221008214924.841@kylheku.com> <thubhv$g0bh$1@dont-email.me>
Injection-Date: Sun, 9 Oct 2022 11:43:42 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2654354"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sun, 9 Oct 2022 11:43 UTC

In article <thubhv$g0bh$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
....
>I think I spoke too soon previously about "[not] rewriting the
>algorithm"; if it's a hard coded shell limit then there's no other way
>[in shell], I suppose.

Is recompiling the shell binary an option?

(I don't know if it is as simple as changing a parameter and recompiling.
Have you asked on any other forums - perhaps one more about ksh internals -
i.e., at the C level - rather than just being about shell programming in
general)

--
After Using Gender Slur Against AOC, GOP Rep. Yoyo Won't Apologize 'For Loving God'.

That's so sweet...

Re: Kornshell limit - recursion depth

<thueo6$g8i3$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6730&group=comp.unix.shell#6730

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell limit - recursion depth
Date: Sun, 9 Oct 2022 14:27:49 +0200
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <thueo6$g8i3$1@dont-email.me>
References: <thsvs4$9o2u$1@dont-email.me> <20221008214924.841@kylheku.com>
<thubhv$g0bh$1@dont-email.me> <thuc5e$2h04i$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 9 Oct 2022 12:27:50 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="b0bf0a34aa466265c1f32e5613c5340f";
logging-data="533059"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/vjvnVRAu8eURd/lmH8ZYU"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:0t0rwjlZWvFuXnj2chm/SsVMcF8=
In-Reply-To: <thuc5e$2h04i$1@news.xmission.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sun, 9 Oct 2022 12:27 UTC

On 09.10.2022 13:43, Kenny McCormack wrote:
> In article <thubhv$g0bh$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> ...
>> I think I spoke too soon previously about "[not] rewriting the
>> algorithm"; if it's a hard coded shell limit then there's no other way
>> [in shell], I suppose.
>
> Is recompiling the shell binary an option?

I thought about it when I realized that it's a hard coded limit. But,
without going into the details, on the legacy system I am preferred
working on it may be an issue. The (AT&T) ksh build process is also
non-standard (not the usual configure/make/install incantation), and
though the build worked smoothly when I did that on a contemporary
system many years ago, I'd rather not want to try here (failed with
missing libs and the like). When I looked into the code it's also
not that clear to me whether I can just change a constant; I found
at least two that sound like it and I cannot tell whether it's safe
to change any of them without subtle side effects; it would certainly
need some time to check that. And then I would have an isolated shell
clone. - These were about my thoughts when pondering about it.

>
> (I don't know if it is as simple as changing a parameter and recompiling.
> Have you asked on any other forums - perhaps one more about ksh internals -
> i.e., at the C level - rather than just being about shell programming in
> general)

Not yet.

To be honest, I'd rather like to focus on the algorithmic side, not
dive too deep into the tool details.

From the times (last century) when I programmed more than I do today
I recall compiler to allow setting parameters for memory consumption,
stack depth, and the like. Now I have to admit that shell was likely
just not the right tool for my prototyping approach.

Janis

Re: Kornshell limit - recursion depth

<thugj9$2h1m7$1@news.xmission.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6731&group=comp.unix.shell#6731

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell limit - recursion depth
Date: Sun, 9 Oct 2022 12:59:21 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <thugj9$2h1m7$1@news.xmission.com>
References: <thsvs4$9o2u$1@dont-email.me> <thubhv$g0bh$1@dont-email.me> <thuc5e$2h04i$1@news.xmission.com> <thueo6$g8i3$1@dont-email.me>
Injection-Date: Sun, 9 Oct 2022 12:59:21 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2655943"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sun, 9 Oct 2022 12:59 UTC

In article <thueo6$g8i3$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
....
>> (I don't know if it is as simple as changing a parameter and recompiling.
>> Have you asked on any other forums - perhaps one more about ksh internals -
>> i.e., at the C level - rather than just being about shell programming in
>> general)
>
>Not yet.
>
>To be honest, I'd rather like to focus on the algorithmic side, not
>dive too deep into the tool details.

Yes, definitely. It's just that in your OP, you stated that changing the
algorithm was not an option.

You have since softened your position on that front.

>From the times (last century) when I programmed more than I do today
>I recall compiler to allow setting parameters for memory consumption,
>stack depth, and the like. Now I have to admit that shell was likely
>just not the right tool for my prototyping approach.

Yes, I'm sure that thought was on most people's minds when reading this
thread. I think that's why you see a lot of those "Don't program in shell"
screeds - from people who started something in shell and it just grew and
grew until it became unmanageable (generally, by hitting some hard limit or
bug/flaw in the shell implementation) and then wished they'd done it
differently (i.e., in a different language) from the start. But of course,
it is too late to change now...

--
Faced with the choice between changing one's mind and proving that there is
no need to do so, almost everyone gets busy on the proof.

- John Kenneth Galbraith -

Re: Kornshell limit - recursion depth

<slrntk5ioh.dk4.naddy@lorvorc.mips.inka.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6732&group=comp.unix.shell#6732

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: naddy@mips.inka.de (Christian Weisgerber)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell limit - recursion depth
Date: Sun, 9 Oct 2022 13:22:25 -0000 (UTC)
Message-ID: <slrntk5ioh.dk4.naddy@lorvorc.mips.inka.de>
References: <thsvs4$9o2u$1@dont-email.me> <20221008214924.841@kylheku.com>
<thubhv$g0bh$1@dont-email.me>
Injection-Date: Sun, 9 Oct 2022 13:22:25 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
logging-data="13957"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Christian Weisgerber - Sun, 9 Oct 2022 13:22 UTC

On 2022-10-09, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

> I think I spoke too soon previously about "[not] rewriting the
> algorithm"; if it's a hard coded shell limit then there's no other way
> [in shell], I suppose.

Why do you keep repeating "if"? How about checking the source?
I don't know what "ksh" you use, but a brief look at ksh93 1.0.3
shows that...

* It is indeed a fixed limit.
https://github.com/ksh93/ksh/blob/v1.0.3/src/cmd/ksh93/sh/xec.c#L3081

* That limit is defined to 1024.
https://github.com/ksh93/ksh/blob/v1.0.3/src/cmd/ksh93/include/path.h#L44

I don't even know how the ksh93 code base is organized, I just
grepped for the error message and followed the trail.

--
Christian "naddy" Weisgerber naddy@mips.inka.de

Re: Kornshell limit - recursion depth

<thuii0$gjld$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6733&group=comp.unix.shell#6733

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell limit - recursion depth
Date: Sun, 9 Oct 2022 15:32:48 +0200
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <thuii0$gjld$1@dont-email.me>
References: <thsvs4$9o2u$1@dont-email.me> <thubhv$g0bh$1@dont-email.me>
<thuc5e$2h04i$1@news.xmission.com> <thueo6$g8i3$1@dont-email.me>
<thugj9$2h1m7$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 9 Oct 2022 13:32:48 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="b0bf0a34aa466265c1f32e5613c5340f";
logging-data="544429"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+uuBkHDFUL7+jhqoCzvX+P"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:GitxRTvzw17Vc9mF3oyYdddoUxo=
In-Reply-To: <thugj9$2h1m7$1@news.xmission.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sun, 9 Oct 2022 13:32 UTC

On 09.10.2022 14:59, Kenny McCormack wrote:
> In article <thueo6$g8i3$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> ...
>>
>> To be honest, I'd rather like to focus on the algorithmic side, not
>> dive too deep into the tool details.
>
> Yes, definitely. It's just that in your OP, you stated that changing the
> algorithm was not an option.

That was my first impulse. Given the options, I was wrong.

>
> You have since softened your position on that front.

The Gory Reality hit me quite effective.

>
>>From the times (last century) when I programmed more than I do today
>> I recall compiler to allow setting parameters for memory consumption,
>> stack depth, and the like. Now I have to admit that shell was likely
>> just not the right tool for my prototyping approach.
>
> Yes, I'm sure that thought was on most people's minds when reading this
> thread. I think that's why you see a lot of those "Don't program in shell"
> screeds - from people who started something in shell and it just grew and
> grew until it became unmanageable (generally, by hitting some hard limit or
> bug/flaw in the shell implementation) and then wished they'd done it
> differently (i.e., in a different language) from the start. But of course,
> it is too late to change now...

I'm not sure it's too late. After all I'm using the shell just for the
"rapid prototyping"; now it's just "prototyping" (no "rapid" any more).

Kornshell is a bit treacherous; it supports so many advanced features
(type system, FP arithmetic, etc.) that you can reach quite far using
it for algorithmic solutions. But then there's a hard stop at places
where one wouldn't expect it.

Janis

Re: Kornshell limit - recursion depth

<thuir9$gkbm$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6734&group=comp.unix.shell#6734

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell limit - recursion depth
Date: Sun, 9 Oct 2022 15:37:45 +0200
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <thuir9$gkbm$1@dont-email.me>
References: <thsvs4$9o2u$1@dont-email.me> <20221008214924.841@kylheku.com>
<thubhv$g0bh$1@dont-email.me> <slrntk5ioh.dk4.naddy@lorvorc.mips.inka.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 9 Oct 2022 13:37:45 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="b0bf0a34aa466265c1f32e5613c5340f";
logging-data="545142"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/oaKk6YzevbqITUw+Nef74"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:lSAavQ2ESiN4tHovRP78RbsszMM=
In-Reply-To: <slrntk5ioh.dk4.naddy@lorvorc.mips.inka.de>
 by: Janis Papanagnou - Sun, 9 Oct 2022 13:37 UTC

On 09.10.2022 15:22, Christian Weisgerber wrote:
> On 2022-10-09, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>
>> I think I spoke too soon previously about "[not] rewriting the
>> algorithm"; if it's a hard coded shell limit then there's no other way
>> [in shell], I suppose.
>
> Why do you keep repeating "if"? How about checking the source?

I did. - And I am still unsure (as written elsethread).

> I don't know what "ksh" you use, but a brief look at ksh93 1.0.3
> shows that...

I'm using the standard AT&T ksh 93u+ (2012-08-01).

I cannot tell about any clones you are referring to. (I've never heard
of "1.0.3" nor do I use it.)

Janis

>
> * It is indeed a fixed limit.
> https://github.com/ksh93/ksh/blob/v1.0.3/src/cmd/ksh93/sh/xec.c#L3081
>
> * That limit is defined to 1024.
> https://github.com/ksh93/ksh/blob/v1.0.3/src/cmd/ksh93/include/path.h#L44
>
> I don't even know how the ksh93 code base is organized, I just
> grepped for the error message and followed the trail.
>

Re: Kornshell limit - recursion depth

<20221009100450.69@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6737&group=comp.unix.shell#6737

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell limit - recursion depth
Date: Sun, 9 Oct 2022 18:13:31 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 169
Message-ID: <20221009100450.69@kylheku.com>
References: <thsvs4$9o2u$1@dont-email.me> <20221008214924.841@kylheku.com>
<thubhv$g0bh$1@dont-email.me>
Injection-Date: Sun, 9 Oct 2022 18:13:31 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="dceb0821f384fa6a9a5ab7b065967b1a";
logging-data="592056"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19qGKNMrXXlMGklL4gnmSKqdnbWs4SFRzw="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:2oPOK/gArjiohNPFpNVG8H+znHw=
 by: Kaz Kylheku - Sun, 9 Oct 2022 18:13 UTC

On 2022-10-09, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> On 09.10.2022 07:29, Kaz Kylheku wrote:
>> On 2022-10-08, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>>> In Kornshell I wrote a recursive function that (in practice) requires a
>>> maximum recursion depth of about 3000. There's obviously a fixed limit
>>> defined that lies around 1024 (zsh, for example, has a limit of 1000,
>>> it seems); a test program and the error message:
>>>
>>> #!/usr/bin/ksh
>>> typeset l=0
>>> function f { print $((++l)) ; f ;}
>>> f
>>>
>>> ...
>>> 1023
>>> 1024
>>> 1025
>>> ...: f[3]: f: line 3: f: recursion too deep
>>
>> Is this diagnostic literally accurate?
>
> I omitted the data lines 1..1022 (that contain the respective values)
> where I wrote "..." and also the script name where the second "..."
> is, and I manually added the the #! line for informational purposes
> (where the script had a blank line; I always feed scripts explicitly
> to the interpreter, like 'ksh testscript', in case of tests).
>
>> What would happen if we wrote a
>> script that contains over 1000 differently named functions that call
>> each other in a chain?
>
> I haven't tried. (My guess is it would trigger.) - ...quick test with
>
> function f { print f=$((++ff)) ; g ;}
> function g { print g=$((++gg)) ; f ;}
> f
>
> ...
> g=511
> f=512
> g=512
> f=513
> rec[4]: f[2]: g: line 3: g: recursion too deep
>
>> That's not recursion!
>
> No direct recursion, but an indirect one. - I think the naming is okay
> but we can also call it a call stack limit.
>
>>>
>>> Any good ideas how to handle/circumvent/extend that limit (in ksh)?
>>>
>>>
>>> N.B.: Rewriting the (8-branch-cascading) algorithm is not an option.
>>
>> Is there a particular branch that generates the depth; and is
>> it a tail call? Or could it be turned into one?
>
> It's a cascading recursion with eight possible call branches like
>
> function f { c1 && f ; c2 && f ; ... ; c8 && f ;} # c1..c8: conditions
>
> so it's no tail recursion special case and there's no preferred branch.

Well, the c8 && f is definitely a tail call. However, that may not
be where the depth is.

The c1 && f isn't a tail call because the function continues
after it returns, and the conditions aren't mutually exlusive.

An example of this kind of function is an N-ary tree traversal.
Say a tree with up to 8-way branching:

function f (node) {
if (node.children > 0)
f(node.child[0])
if (node.children > 1)
f(node.child[0])
...
if (node.children > 7)
f(node.child[7])
}

E.g. in lisp we have binary nodes, conses with car and cdr.
Most lists grow in the cdr direction, so tail calling on the cdr
case keeps the stack shallow.

This is an issue for garbage collectors, which have to traverse whatever
is reachable, however the application has chosen to shape it.

The application can create cruft in the heap using non-recursive
techniques which then choke a recursive garbage collector.

There are stackless techniques for garbage collection via
"pointer reversal". When the garbage collector follows some link
into an object, it picks one of the pointers in *that* object
and stashes the incoming pointer. Before doing that, it removes
that child pointer, and recurses on that child, passing it
its own address as the next pointer.

Basically, the backwards pointers for returning are stored
into the object graph itself, the originals bein restored
when the reverse path is taken.

It goes something like this:

// stacklessly traverse "3-node": node with 3 child pointers
function visit_3_node(node, escape_pointer)
{
switch (node.traversal_state) {
case UNTRAVERSED:
{
traverse_next = node.child[0]
node.child[0] = escape_pointer
node.state = TRAVERSED_0

// tail call!!!
// child[0] is traversed next, and *its* escape_pointer
// is just node, so it will return here.
return top_level_visit_fn(traverse_next, node)
}
case TRAVERSED_0:
{
orig_escape_pointer = node.child[0]
traverse_next = node.child[1]
node.child[0] = escape_pointer // restore child[0]
node.child[1] = orig_escape_pointer // move to child[1]

node.state = TRAVERSED_1
// child[1] traversed next, again with pointer back to here
return top_level_visit_fn(traverse_next, node)
}
case TRAVERSED_1:
{
// One child left to traverse: different handling.
orig_escape_pointer = node.child[1] // recover orig ptr

node.child[1] = escape_pointer // restore child[1]

// We don't stash the orig_escape_pointer any more.
// Just go to child[2] and pass the original escape
// pointer as the next object to go to (i.e. our caller's).

node.state = TRAVERSED_2; // traversed 0, 1, 2: all done.
return top_level_visit_fn(node.child[2], orig_escape_pointer)
}
}

Basically it is just like continuation passing style (CPS), where the
continuation we are passing down isn't a function, but just pointer to
the object in the graph where to continue. Because the continuation
isn't a function, we simulate one with a state machine; the state
we switch on gives us a kidn of instruction pointer to move through
the traversal cases of the function.

> Frankly, I cannot say whether it could be transformed - I mean without
> explicitly organizing the call stack. I've done that with special cases
> of a (simple, 2-branch) cascading function (fib; see comp.lang,awk the
> post "Yet another obfuscated Awk code", Jan. 2022), but here I am lost.

Language expressiveness is an issue. E.g. how nicely/easily can we code
a pointer-reversal state machine (if such as thing is necessary) in
shell?

:)

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: Kornshell limit - recursion depth

<20221009111612.548@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6738&group=comp.unix.shell#6738

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell limit - recursion depth
Date: Sun, 9 Oct 2022 18:25:59 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 127
Message-ID: <20221009111612.548@kylheku.com>
References: <thsvs4$9o2u$1@dont-email.me> <20221008214924.841@kylheku.com>
<thubhv$g0bh$1@dont-email.me>
Injection-Date: Sun, 9 Oct 2022 18:25:59 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="dceb0821f384fa6a9a5ab7b065967b1a";
logging-data="592056"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/daNvsEipm5i3QsfQ+5cZrFUG/pZB4wUY="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:QM77X94QXvA5SB+rKgxak25oVgM=
 by: Kaz Kylheku - Sun, 9 Oct 2022 18:25 UTC

On 2022-10-09, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> On 09.10.2022 07:29, Kaz Kylheku wrote:
>> On 2022-10-08, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>>> In Kornshell I wrote a recursive function that (in practice) requires a
>>> maximum recursion depth of about 3000. There's obviously a fixed limit
>>> defined that lies around 1024 (zsh, for example, has a limit of 1000,
>>> it seems); a test program and the error message:
>>>
>>> #!/usr/bin/ksh
>>> typeset l=0
>>> function f { print $((++l)) ; f ;}
>>> f
>>>
>>> ...
>>> 1023
>>> 1024
>>> 1025
>>> ...: f[3]: f: line 3: f: recursion too deep
>>
>> Is this diagnostic literally accurate?
>
> I omitted the data lines 1..1022 (that contain the respective values)
> where I wrote "..." and also the script name where the second "..."
> is, and I manually added the the #! line for informational purposes
> (where the script had a blank line; I always feed scripts explicitly
> to the interpreter, like 'ksh testscript', in case of tests).
>
>> What would happen if we wrote a
>> script that contains over 1000 differently named functions that call
>> each other in a chain?
>
> I haven't tried. (My guess is it would trigger.) - ...quick test with
>
> function f { print f=$((++ff)) ; g ;}
> function g { print g=$((++gg)) ; f ;}
> f
>
> ...
> g=511
> f=512
> g=512
> f=513
> rec[4]: f[2]: g: line 3: g: recursion too deep
>
>> That's not recursion!
>
> No direct recursion, but an indirect one. - I think the naming is okay
> but we can also call it a call stack limit.
>
>>>
>>> Any good ideas how to handle/circumvent/extend that limit (in ksh)?
>>>
>>>
>>> N.B.: Rewriting the (8-branch-cascading) algorithm is not an option.
>>
>> Is there a particular branch that generates the depth; and is
>> it a tail call? Or could it be turned into one?
>
> It's a cascading recursion with eight possible call branches like
>
> function f { c1 && f ; c2 && f ; ... ; c8 && f ;} # c1..c8: conditions
>
> so it's no tail recursion special case and there's no preferred branch.
>
> Frankly, I cannot say whether it could be transformed - I mean without
> explicitly organizing the call stack. I've done that with special cases
> of a (simple, 2-branch) cascading function (fib; see comp.lang,awk the
> post "Yet another obfuscated Awk code", Jan. 2022), but here I am lost.
>
>>
>> Without changing an algorithm, we may be able to manually convert some
>> key tail call in it into iteration, while keeping the others recursive.
>
> I think I spoke too soon previously about "[not] rewriting the
> algorithm"; if it's a hard coded shell limit then there's no other way
> [in shell], I suppose.

Before thinking about things like tail recursion and whatever crap
I've been talking about, one thing that can be done is to reduce
the number of function calls by a factor.

This is done simply by manually inlining the recursive cases
to whatever depth is required.

If you need a call of around 3000, and the language artificially
restricts to 1000 well before the stack is exhausted, you can
fool it by manually inlining three levels of recursion.

The function blows up in size and complexity, to be sure, but
in a regular way which you can document as being manually
expanded recursion. (E.g. provide the simple version in a block
comment, with a brief explanation.)

E.g. here is a two-level expansion of your simplified function schema:

function f()
{
if (cond1) {
cond1 && f # I eval cond1 twice; it may have side effects
cond2 && f
...
cond8 && f
}
if (cond2) {
cond1 && f
cond2 && f
...
cond8 && f
}

...
if (cond8) {
cond1 && f
cond2 && f
...
cond8 && f
}
}

A macro preprocessor would help here, clearly.

If this were Awk, we could use cppawk, which gives you the C
preprocessor in front of Awk.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: Kornshell limit - recursion depth

<thvbs2$ipdv$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6739&group=comp.unix.shell#6739

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell limit - recursion depth
Date: Sun, 9 Oct 2022 22:44:49 +0200
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <thvbs2$ipdv$1@dont-email.me>
References: <thsvs4$9o2u$1@dont-email.me> <20221008214924.841@kylheku.com>
<thubhv$g0bh$1@dont-email.me> <20221009111612.548@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 9 Oct 2022 20:44:50 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="b0bf0a34aa466265c1f32e5613c5340f";
logging-data="615871"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/U1TgwFbQhhHPixL7LzelM"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:ghgM0LX+xAKMwaNxt+OO432/u4c=
In-Reply-To: <20221009111612.548@kylheku.com>
 by: Janis Papanagnou - Sun, 9 Oct 2022 20:44 UTC

On 09.10.2022 20:25, Kaz Kylheku wrote:
>> [...]
>
> Before thinking about things like tail recursion and whatever crap
> I've been talking about, one thing that can be done is to reduce
> the number of function calls by a factor.
>
> This is done simply by manually inlining the recursive cases
> to whatever depth is required.
>
> If you need a call of around 3000, and the language artificially
> restricts to 1000 well before the stack is exhausted, you can
> fool it by manually inlining three levels of recursion.

A good idea. - Thanks!

Janis

> [...]

Re: Kornshell limit - recursion depth

<ti53cd$17cgm$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6743&group=comp.unix.shell#6743

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell limit - recursion depth
Date: Wed, 12 Oct 2022 02:56:45 +0200
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <ti53cd$17cgm$1@dont-email.me>
References: <thsvs4$9o2u$1@dont-email.me> <thubhv$g0bh$1@dont-email.me>
<thuc5e$2h04i$1@news.xmission.com> <thueo6$g8i3$1@dont-email.me>
<thugj9$2h1m7$1@news.xmission.com> <thuii0$gjld$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 12 Oct 2022 00:56:45 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="cc5aa46dfaa9ccd3b6fb61d46172d55f";
logging-data="1290774"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18okLHsu8mW1R/CDZa+3z6o"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:GTWj9Da9I1U9WQK5J3mbLEC8t0I=
In-Reply-To: <thuii0$gjld$1@dont-email.me>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Wed, 12 Oct 2022 00:56 UTC

On 09.10.2022 15:32, Janis Papanagnou wrote:
> On 09.10.2022 14:59, Kenny McCormack wrote:
>>
>> Yes, I'm sure that thought was on most people's minds when reading this
>> thread. I think that's why you see a lot of those "Don't program in shell"
>> screeds - from people who started something in shell and it just grew and
>> grew until it became unmanageable (generally, by hitting some hard limit or
>> bug/flaw in the shell implementation) and then wished they'd done it
>> differently (i.e., in a different language) from the start. But of course,
>> it is too late to change now...
>
> I'm not sure it's too late. After all I'm using the shell just for the
> "rapid prototyping"; now it's just "prototyping" (no "rapid" any more).

Since the algorithm was already existing in ksh, a re-implementation
in Awk was done fast. The Awk code is terse and much better readable.
It is running a magnitude faster than shell. No recursion depth limit
or other obstacles appeared. ("+1" for GNU Awk with multi-dimensional
arrays support which contributed here as well.)

>
> Kornshell is a bit treacherous; it supports so many advanced features
> (type system, FP arithmetic, etc.) that you can reach quite far using
> it for algorithmic solutions. But then there's a hard stop at places
> where one wouldn't expect it.
>
> Janis
>

Re: Kornshell limit - recursion depth

<tijili$2rqa1$1@news.xmission.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6744&group=comp.unix.shell#6744

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell limit - recursion depth
Date: Mon, 17 Oct 2022 12:43:30 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <tijili$2rqa1$1@news.xmission.com>
References: <thsvs4$9o2u$1@dont-email.me> <thugj9$2h1m7$1@news.xmission.com> <thuii0$gjld$1@dont-email.me> <ti53cd$17cgm$1@dont-email.me>
Injection-Date: Mon, 17 Oct 2022 12:43:30 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3008833"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Mon, 17 Oct 2022 12:43 UTC

In article <ti53cd$17cgm$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>On 09.10.2022 15:32, Janis Papanagnou wrote:
>> On 09.10.2022 14:59, Kenny McCormack wrote:
>>>
>>> Yes, I'm sure that thought was on most people's minds when reading this
>>> thread. I think that's why you see a lot of those "Don't program in shell"
>>> screeds - from people who started something in shell and it just grew and
>>> grew until it became unmanageable (generally, by hitting some hard limit or
>>> bug/flaw in the shell implementation) and then wished they'd done it
>>> differently (i.e., in a different language) from the start. But of course,
>>> it is too late to change now...
>>
>> I'm not sure it's too late. After all I'm using the shell just for the
>> "rapid prototyping"; now it's just "prototyping" (no "rapid" any more).
>
>Since the algorithm was already existing in ksh, a re-implementation
>in Awk was done fast. The Awk code is terse and much better readable.
>It is running a magnitude faster than shell. No recursion depth limit
>or other obstacles appeared. ("+1" for GNU Awk with multi-dimensional
>arrays support which contributed here as well.)

I think you did the right thing.

--
A Catholic woman tells her husband to buy Viagra.

A Jewish woman tells her husband to buy Pfizer.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor