Bash, tar, and broken pipe
heinz at cc.univie.ac.at
heinz at cc.univie.ac.at
Fri May 17 19:34:38 AEST 1991
In <1991May15.155040.19078 at ssd.kodak.com> weimer at garden.ssd.kodak.com (Gary Weimer (253-7796)) writes:
>In article <586 at kepler1.kepler.com>, jwu at 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 at sophie.pri.univie.ac.at / what I'm doing ! / /--
-/ Vienna University, Austria / (Sledge Hammer) / /---
--------------------------------------------------------------------------------
--
--
--------------------------------------------------------------------------------
More information about the Comp.unix.shell
mailing list