bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: recursion crash


From: Paul Jarc
Subject: Re: recursion crash
Date: Mon, 29 Oct 2001 11:03:03 -0500
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/20.7 (i386-redhat-linux-gnu)

Alex Turner <ajturner@armature.com> wrote:
> #!/usr/bin/bash
> declare -i n
> n=0
> r()
> {
>    echo $n
>    n=n+1
>    r
> }
> r
>
> The above script will crash bash dew to a segmentation violation.

How did you expect it to behave differently?  Your computer has only a
finite amount of memory; infinite recursion will eventually use it
all, and continue trying to use more.  A real functional program would
not use infinite recursion and would (probably) not encounter this
problem.  bash could be changed to give an error message instead of
crashing, but I imagine that might have a significant performance
impact.


paul



reply via email to

[Prev in Thread] Current Thread [Next in Thread]