Bug 217055 - Consolidate random sleeps in periodic scripts

Alan Somers asomers at freebsd.org
Fri Mar 31 05:05:13 UTC 2017


On Thu, Feb 16, 2017 at 1:26 PM, Cy Schubert <Cy.Schubert at komquats.com> wrote:
> 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.

Under review at https://reviews.freebsd.org/D10211 .  Please direct
further discussion to the review.


More information about the freebsd-pkg mailing list