Bug 217055 - Consolidate random sleeps in periodic scripts

Cy Schubert Cy.Schubert at komquats.com
Thu Feb 16 20:26:51 UTC 2017


In message <86zihmwlth.fsf at desk.des.no>, =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?
= w
rites:
> Cy Schubert <Cy.Schubert at komquats.com> writes:
> > "Dag-Erling Smørgrav" <des at des.no> writes:
> > > This won't work, because && forks.  You need:
> > > 
> > >    if [ -t 0 ] ; then ... ; fi
> > Are you sure?
> 
> Maybe it varies from shell to shell...  or maybe I confused it with
> other constructs like 'grep foo bar | while read line' (which definitely
> doesn't work).  I consider it bad style, but that's a matter of taste.
> I prefer to use && and || only for error conditions and loop control.

Maybe. I tested this on Bourne, ksh, bash, zsh, csh and 44bsd-csh on 
FreeBSD and bash on Linux. I don't have access to any Solaris or AT&T 
servers any more. (I am told that Solaris 11 replaced /bin/sh with bash.)

If the command after a test is a one-liner, like my proposed patch, then I 
prefer to put it on the same line. If it's more than one line then it 
should go in an if block. Otherwise it's ugly and hard to follow. Just a 
difference in preference I suppose.


-- 
Cheers,
Cy Schubert <Cy.Schubert at cschubert.com>
FreeBSD UNIX:  <cy at FreeBSD.org>   Web:  http://www.FreeBSD.org

	The need of the many outweighs the greed of the few.




More information about the freebsd-pkg mailing list