Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!uunet!email!swdsrv.edvz.univie.ac.at!heinz From: heinz@cc.univie.ac.at Newsgroups: comp.unix.shell Subject: Re: Bash, tar, and broken pipe Message-ID: Date: 17 May 91 09:34:38 GMT References: <586@kepler1.kepler.com> <1991May15.155040.19078@ssd.kodak.com> Sender: news@swdsrv.edvz.univie.ac.at Organization: Vienna University Computer Center Lines: 59 Nntp-Posting-Host: sophie.pri.univie.ac.at In <1991May15.155040.19078@ssd.kodak.com> weimer@garden.ssd.kodak.com (Gary Weimer (253-7796)) writes: >In article <586@kepler1.kepler.com>, jwu@kepler.com (Jasper Wu) writes: >|> >|> I have some problem when using pipelined tar in bash and hope someone >|> can help me find out why. >|> >|> When I do >|> zcat foo.tar.Z | tar tvfB - >|> or uncompress < foo.tar.Z | tar tvfB - >|> >|> it gives me the table of contents correctly but reports an error >|> message "Broken pipe" to stderr when it finishes. However, if i add >|> a "cat" to the pipeline as >|> cat foo.tar.Z | uncompress | tar tvfB - >|> >|> then it works fine (i.e., no error message). All commands above work fine >|> in csh or sh. >In csh I use: > uncompress -c foo.tar.Z | tar tvf - > ^^ >(I've never had a problem not using B for tar). I don't know if this >will fix your problem or not. This does *not* fix the problem. I've been using bash for quite a long time now, and have made the same experience as Jasper. For bash, it doesn't make any difference whether you use 'compress -c' or 'zcat' (because it's the same program anyway - zcat, compress and uncompress are links to the same program), and it doesn't make any difference whether you use 'tar' with -B or not. I'm sorry I can't give a solution to the problem - all that I know is that bash reports a broken pipe if one of the processes making up the pipe is killed or terminated abnormally (well, it doesn't have to be terminated abnormally, it only needs to be just terminated). As I didn't have time to look into bash's source code yet, I don't know if the actual problem is a bug in bash or an abnormal behaviour of zcat which isn't re- vealed by the other shells. It also might be a 'timing prob- lem' as zcat surely terminates before tar, and this may cause bash to report the pipe as being broken. -- -- -------------------------------------------------------------------------------- ---/ Heinz M. Herbeck / Trust me, I know / /- --/ heinz@sophie.pri.univie.ac.at / what I'm doing ! / /-- -/ Vienna University, Austria / (Sledge Hammer) / /--- -------------------------------------------------------------------------------- -- -- --------------------------------------------------------------------------------