[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using && in commands
From: |
Robert Mecklenburg |
Subject: |
Re: Using && in commands |
Date: |
Thu, 6 Nov 2003 16:02:15 -0700 |
From: "Noel Yap" <address@hidden>
> IIRC, make will spawn a shell for the sed command due to to '>' in the
> command line. I believe make will then fork/exec for the mv command.
> Since make is already shelling out for the sed command, I see no reason
> not to use that shell to do the conditional mv as well.
>
> If you're worried about legibility, you could write the rule as:
>
> foo:
> sed ... > /tmp/x && \
> mv /tmp/x y
Good thinking, I hadn't considered performance.
But I'm not sure I agree. The two command version will fork/exec three
times 1) make forks bash; 2) bash forks sed; 3) make forks mv. The &&
version also forks three times 1) make forks bash; 2) bash forks sed; 3)
bash forks sed. I'm not sure I see a performance argument.
I do see a clarity argument (not only legibility). Make's job is to ensure
a command has finished with success before starting the next command. Why
use a (slightly) arcane syntax of the shell when the "obvious" command is
intended to work? I'm still mulling this over.
More thoughts?
Robert