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}" > 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 > 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. So I would apply any your solution that works on normal case. ciao cate