Email address obfuscation in effect -- please
click here to turn it off.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
On Thu, 3 Mar 2005 14:05:52 -0600, Mark Rages <EMAIL:PROTECTED> wrote:
> Ok, so here's one solution from some Perl guys:
>
> http://use.perl.org/~cog/journal/18948
>
> yuck. does everybody do their shell scripts this way?
Probably not, but this is a well-known Unix shell "gotcha". Things are
even worse in csh, I think. The perl solution given here is an
attempt to plug the problems with sh using perl, which is a
historically ancient use of that tool. There are shell idioms to get
around this stuff, but I agree that it really sucks when an intuitive
use of piping stuff around gives you obnoxious results.
But as for your specific example:
> > > > ( /bin/false | gzip > /dev/null ) || echo fail
Clearly shouldn't do what you want. You told gzip to take its
standard input from a pipe, and even if a non-zero exit code is
raised, I can't see how what you did should prevent gzip from sucking
up it's stdin and compressing the result, which gives some trivial
file of minimum length So check this out:
jonathan% false | gzip> dorky.gz
jonathan% ls -l dorky.gz
-rw-r--r-- 1 jonathan staff 20 3 Mar 14:49 dorky.gz
jonathan% gzip > dorky2.gz # I hit cntrl-d to close stdin
jonathan% ls -l dorky2.gz
-rw-r--r-- 1 jonathan staff 20 3 Mar 14:49 dorky2.gz
Now, if you want my opinion, this (under tcsh) is much nastier:
jonathan% echo "" | gzip > dorky3.gz
jonathan% ls -l dorky3.gz
-rw-r--r-- 1 jonathan staff 21 3 Mar 14:51 dorky3.gz
Echo can never keep its mouth completely shut. Grr...
jking
_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members