Date: Thu, 16 Feb 2017 12:26:44 -0800 From: Cy Schubert <Cy.Schubert@komquats.com> To: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no> Cc: Cy Schubert <Cy.Schubert@komquats.com>, Alan Somers <asomers@freebsd.org>, scrappy@freebsd.org, Brian Somers <brian@freebsd.org>, freebsd-bugzilla@ayaken.net, Cy Schubert <cy@freebsd.org>, pkg@freebsd.org Subject: Re: Bug 217055 - Consolidate random sleeps in periodic scripts Message-ID: <201702162026.v1GKQivr096824@slippy.cwsent.com> In-Reply-To: Message from =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no> of "Thu, 16 Feb 2017 10:02:02 %2B0100." <86zihmwlth.fsf@desk.des.no>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <86zihmwlth.fsf@desk.des.no>, =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav? = w rites: > Cy Schubert <Cy.Schubert@komquats.com> writes: > > "Dag-Erling Smørgrav" <des@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@cschubert.com> FreeBSD UNIX: <cy@FreeBSD.org> Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201702162026.v1GKQivr096824>