*BSD News Article 83446


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.eng.convex.com!newshost.convex.com!newsgate.duke.edu!news.mathworks.com!newsfeed.internetmci.com!csn!nntp-xfer-1.csn.net!ncar!newshost.lanl.gov!crs
From: crs@lanl.gov (Charlie Sorsby)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: cat foo* > foo.bar    causes infinite loop
Date: 22 Nov 1996 22:29:30 GMT
Organization: Los Alamos National Laboratory
Lines: 69
Message-ID: <5759gb$79o@newshost.lanl.gov>
References: <328A1236.32C4@pilot.msu.edu> <56itkk$h59$1@nic.wat.hookup.net> <56mktc$b4a@uriah.heep.sax.de> <56vqp9$1a5@anorak.coverform.lan>
Reply-To: crs@hamlet.lanl.gov
NNTP-Posting-Host: hamlet.lanl.gov

In article <56vqp9$1a5@anorak.coverform.lan>,
Brian Somers <brian%anorak.coverform.lan@awfulhak.demon.co.uk> wrote:
= In article <56mktc$b4a@uriah.heep.sax.de>,
= 	j@uriah.heep.sax.de (J Wunsch) writes:
= : schaffer@wat.hookup.net wrote:
= : 
= >> You should expect this behavior with any shell (no, I haven't tried):
= >> basically, the shell first looks for pipes, redirections etc.  For
= >> redirected stdout it creates the target file, then evaluates the command
= >> (cat foo*).
= : 
= : Just for the records, all of the available shells for FreeBSD (csh,
= : tcsh, sh, bash, zsh) experience this behaviour, except the pdksh.
= : 
= : (I haven't tried to get a genuine ksh, but somebody else already
= : responded that it doesn't show this artifact.)
= 
= Hmmmm,
= 
[...Brian's examples deleted for brevity...]
= 
= In fact, I get the same results using the csh and sh (ash) as supplied in
= both the above versions of FreeBSD !  Am I missing something ?

I had posted some time ago that my recollection was that there was
no infinite-loop problem in SunOS.  I've since checked:

SPARCstation II running SunOS 4.1.4, using csh.

H% ls -lg
total 11
drwxr-xr-x  2 crs      staff         512 Nov 22 15:18 ./
drwxr-xr-x 63 crs      staff        6656 Nov 22 15:18 ../
-rw-r--r--  1 crs      staff           2 Nov 22 15:18 foo1
-rw-r--r--  1 crs      staff           2 Nov 22 15:18 foo2
-rw-r--r--  1 crs      staff           2 Nov 22 15:18 foo3
H% cat * > foo.all
cat: input foo.all is output
H% ls -lg
total 12
drwxr-xr-x  2 crs      staff         512 Nov 22 15:19 ./
drwxr-xr-x 63 crs      staff        6656 Nov 22 15:18 ../
-rw-r--r--  1 crs      staff           6 Nov 22 15:19 foo.all
-rw-r--r--  1 crs      staff           2 Nov 22 15:18 foo1
-rw-r--r--  1 crs      staff           2 Nov 22 15:18 foo2
-rw-r--r--  1 crs      staff           2 Nov 22 15:18 foo3
H% 

Just for interest, I then tried again (after foo.all exists and
contains the contents of foo[123].  The result is the same.  It
cats foo[123] into foo.all but will not use the output as input.
One gets the same complaint (cat: input foo.all is output) and when
it's done, foo.all is twice as big as it had been since the same
three files were catted to it (with >> since I have noclobber set)
a second time.  I didn't try it with >! to over-ride noclobber but
surely if an infinite loop were going to form, it would have done
with >> wouldn't it?

= -- 
= Brian <brian%anorak.coverform.lan@awfulhak.demon.co.uk>
=       <http://www.awfulhak.demon.co.uk/>
= Don't _EVER_ lose your sense of humour....


-- 
Best,

Charlie "Older than dirt" Sorsby                         "I'm the NRA!"
       crs@swcp.com crs@hamlet.lanl.gov              Life Member since 1965