*BSD News Article 82854


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mel.connect.com.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!howland.erols.net!news.mathworks.com!uunet!in2.uu.net!news.eden.com!arlut.utexas.edu!mamba!crites
From: "Lee Crites (arl)" <crites@arlut.utexas.edu>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: cat foo* > foo.bar    causes infinite loop
Date: Thu, 14 Nov 1996 12:36:19 -0600
Organization: Applied Research Laboratories - The University of Texas at Austin
Lines: 29
Message-ID: <Pine.SOL.3.95.961114123203.25331D-100000@mamba>
References: <328A1236.32C4@pilot.msu.edu>
NNTP-Posting-Host: mamba.arlut.utexas.edu
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Sender: crites@mamba
To: Ed Symanzik <zik@pilot.msu.edu>
In-Reply-To: <328A1236.32C4@pilot.msu.edu>


On Wed, 13 Nov 1996, Ed Symanzik wrote:

> If I create three files foo1, foo2, and foo3 then run the command
> 
>  cat foo* > foo.bar
> 
> in csh I get an infinite loop (at least until the partition fills up).
> Seems to me that '*' should be evaluated before new files are created.
> I have seen systems that don't behave this way give errors similar to
> "can't open foo.bar for both input and output".

I use csh on several different os's, and the results are the same.  I
tested this on aix (3.2.5, 4.1, and 4.2), and various sun machines.

to get around this try:

foreach fname ( `ls foo.*` )
  cat $fname >> foo.bar
  end

This works because the executed command `ls foo.*` is evaluated up front.

Lee Crites
Senior Systems Consultant
Computer Mavericks
Adonai Enterprises, Inc
adonai@jump.net