correct • elegant • free

△ △

◅ Help, I want to do baaaad things :-)

Shell script help ▻

Better cron output handling?

In article <p7aF4.6$>,
Dave Carmean <> wrote:
>: Have your script copy stdin to a temporary file, and then test whether the
>: file is empty, i.e. something like:
>I didn't really want to do that.  Here's what I came up with:

Which reads the entire input into memory instead.  Your call, but I've
seen enough cron jobs which normally print a couple of lines, but
sometimes go crazy and spew out thousands, that I'd rather use a
temporary file.


>   IFS=''
>   input=`cat -`

That's (Bing!) a UUOHATC.  (Useless Use Of Hyphen Argument To Cat, of
course.)  Some people find comfort in `cat -', but in fact it just means
the same as a bare `cat'.

>   if [ $input ]

I think you'll find

    if [ -n "$input" ]

works for rather more values of input.

Tim Goodwin   | "If you don't know what closures are, you probably don't
Leicester, UK | want to know what closures are." -- Larry Wall

Original headers:

From: (Tim Goodwin)
Subject: Re: Better cron output handling?
Date: 3 Apr 2000 12:54:58 +0100
Message-ID: <8ca0r8$gbr$>
References: <k1PE4.4$>
  <j1RE4.39$YN6.1541@burlma1-snr2> <p7aF4.6$>

△ △

◅ Help, I want to do baaaad things :-)

Shell script help ▻