bug-bash
[Top][All Lists]
Advanced

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

Re: recursive functions in bash


From: Chet Ramey
Subject: Re: recursive functions in bash
Date: Mon, 10 Dec 2007 16:14:54 -0500
User-agent: Thunderbird 2.0.0.9 (Macintosh/20071031)

davedoom wrote:

> I am trying to learn to write recursive functions in bash. As one of my
> first attempts i wrote this program to emulate the system provided tac
> command:
> 
> after playing with it for a good bit, it no longer produces this error
> message:
> malloc: ../bash/subst.c:4135: assertion botched
> realloc: start and end chunk sizes differ
> 
> but it doesn't reverse the file.   What am i doing wrong?  Is there
> something about unix file descriptors I don't understand? 

I can't reproduce the malloc error, but this will never work.  You're
passing a pipe named in /dev/fd to a function that expects to use the
data multiple times.  The first call to `wc' consumes the entire stream.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                       Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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