What is the difference between ; and &&

Louis LeBlanc freebsd at keyslapper.org
Thu Jan 8 06:01:10 PST 2004


On 01/08/04 01:43 PM, Matthew Seaman sat at the `puter and typed:
> On Wed, Jan 07, 2004 at 11:38:58PM +0000, Ceri Davies wrote:
> > On Wed, Jan 07, 2004 at 05:36:42PM -0600, Eric F Crist wrote:
> 
> > > make depend && make && make install
> 
> > [Of course, if the Makefile has it's dependencies correct, then a simple
> >  "make install" will achieve the same thing.]
> 
> Hmmm... Usually 'make depend' generates a dependency Makefile, which
> is .included'ed into the main Makefile on subsequent runs.  That means
> that
> 
>     make depend ; make all
> 
> has a different effect to:
> 
>     make depend all
> 
> Unless make(1) has been taught to keep tabs on it's included Makefiles
> and knows how to re-load them if their modification time changes.  As
> I understood it, that was a trick that gmake(1) could do but that BSD
> make couldn't.
> 
> 	Cheers,
> 
> 	Matthew

I've missed a bit of this thread, so this may be redundant . . .

The primary reason for using 'make depend && make && make install' is
to halt the whole procedure in the event of a failure at any point.
The '&&' separates the commands much the way ';' does, but makes the
execution of each one dependent upon the success of the previous.
This means that 'make' (the second command) will be executed if and
only if 'make depend' succeeds.  Likewise, 'make install' will only be
executed if and only if 'make' is executed and succeeds.

If there is a failure at any point, you won't have nearly so far to
backtrack to find the point of failure.

This is a fantastic method for 'scheduling' multiple build stages
without having to sit at the keyboard.

HTH
Lou
-- 
Louis LeBlanc               leblanc at keyslapper.org
Fully Funded Hobbyist, KeySlapper Extrordinaire :)
http://www.keyslapper.org                     Ô¿Ô¬

Hailing frequencies open, Captain.


More information about the freebsd-questions mailing list