help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using && in commands


From: Paul D. Smith
Subject: Re: Using && in commands
Date: Thu, 6 Nov 2003 18:01:31 -0500

%% Robert Mecklenburg <address@hidden> writes:

  rm> I have often used the shell && operator in commands run from make:
  rm> foo:
  rm>   sed ... > /tmp/x && mv /tmp/x y

  rm> but I am now questioning the value of this.  Obviously, the above
  rm> mv is executed only if sed returns success so it "protects" y from
  rm> accidental clobbering.  However, isn't that exactly what this
  rm> does:

  rm> foo:
  rm>   sed ... > /tmp/x
  rm>   mv /tmp/x y

  rm> Assuming the -i flag isn't used (or .SILENT: etc.), is one form
  rm> preferred over the other?  Right now I prefer the second form.

In the case you give above they are equivalent.  In fact I don't use &&
there.  But in cases like this they are not equivalent:

    foo:
        cd foo && $(MAKE)

Or even something like:

    foo:
        for x in $(LISTOFSTUFF); do \
            something && somethingelse ; \
        done


In other words, I use "&&" when I need everything to run in the same
shell script, and multiple lines where it doesn't.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]