On 2/27/06, Giacomo A. Catenazzi <[EMAIL PROTECTED]> wrote:
> Eddy Petrişor" wrote:
> >>an other maybe better version
> >>
> >>at the beginning (only on home computer)
> >>if [ "${SLEEPTIME}" ] ; then
> >>    SLEEPCMD="sleep ${SLEEPTIME} || true"
> >
> >
> > I don't understand the reason behind the part with "|| true"
> >
> > This should do:
> > SLEEPCMD="type sleep && sleep ${SLEEPTIME}"
>
> I usually put || true because I use a lot of "-e" shell script.
> But I agree, in this (the nested) script is not necessary.
>
>
> > Yes, but is a lot uncleaner than testing for the existance of the
> > cammand, then running it if it does exist.
>
> But it is the standard way. (IIRC).
> The shell (aka the system library) should return 127 if command
> doesn'exists.
>
> Opps. I think the right command should be:
> SLEEPCMD="sleep ${SLEEPTIME}"

Note: I din't understood what has changed, but the test for the
existance of sleep should not miss as it would break the whole
download script instead of gracefully failing ;-)

> > The only thing that I don't like about the solution with:
> >
> > type command && command
> >
> > is that it will generate noise on the console, that's why I prefer:
> >
> > [ ! -z "\`type command\`" ] && command

just tested this, and looks ok:

$ cat aaa.sh
cat <<-EOF
         [ ! -z "\`type sleep\`" ] && sleep 1
EOF

[EMAIL PROTECTED] ~
$ sh aaa.sh > script

[EMAIL PROTECTED] ~
$ cat script
 [ ! -z "`type sleep`" ] && sleep 1

[EMAIL PROTECTED] ~
$ sh script

(here there is a sleep)

I guess this is ok and has no noise.
>
> type is not a POSIX/SuS command, so I think it is better to avoid it.
> [ http://www.unix.org/single_unix_specification/ ]
> On a system without "type" (if such system exists) will not
> execute "sleep".
> Anyway this is not a big issue, because this sleep function is not an
> inportant option, and I think it is resonable to require sane
> implementation to use this extra feature.

type is present in the specification (not sure if this implies that is
POSIX) - see "Utilities" in "Shel&Utilities".

> So I would apply any your solution that works on normal case.
Only the sleep period issue should be fixed first.
Have you made any changes from the zip you send previously?

--
Regards,
EddyP
=============================================
"Imagination is more important than knowledge" A.Einstein

Reply via email to