bug-bash
[Top][All Lists]
Advanced

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

Re: recursion crash


From: Chet Ramey
Subject: Re: recursion crash
Date: Mon, 29 Oct 2001 12:23:42 -0500

> Hi!
> 
> I am writing functional programming in BASH.  Which is really fun and very
> powerful - but I have hit a problem with recursion.
> 
> #!/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.  It gives
> up at r=3234 with:
> 
> GNU bash, version 2.05.0(8)-release (i686-pc-cygwin)

Well, you've got infinite recursion.  Eventually you're going to run out
of stack space, no matter what you do with resource limits.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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