On Wed, Oct 7, 2009 at 8:26 AM, William A. Rowe, Jr.
<[email protected]> wrote:
> Jeff Trawick wrote:
>> On Wed, Oct 7, 2009 at 8:04 AM, William A. Rowe, Jr.
>> <[email protected]> wrote:
>>> Jeff Trawick wrote:
>>>> As far as repairing, I switched to the syntax used elsewhere in the
>>>> makefile. But I'll try the other syntax very shortly.
>>> IIRC that syntax was selected to avert the makefile from aborting in case
>>> of failure.
>>
>> Is this a valid test? (sorry, in the middle of getting the 10 YO off to
>> school)
>
> We don't want the non-valid result code to kill the build in this case. The
> && syntax
> takes care of avoiding further complications, and it should just plug on.
>
Let me play stupid here...
The && syntax says don't rename files (.bak, .new) unless the edit worked.
It won't just plug on because () doesn't ignore errors.
Simple example, with proper syntax:
$ cat Makefile
all:
for i in .bashrc .emacs; do \
echo $$i; \
if test -f $$i; then ( \
cp $$i /tmp/a/b/c && true; \
) fi; \
done
$ make
for i in .bashrc .emacs; do \
echo $i; \
if test -f $i; then ( \
cp $i /tmp/a/b/c; \
) fi; \
done
.bashrc
cp: cannot create regular file `/tmp/a/b/c': No such file or directory
*** Error code 1
make: Fatal error: Command failed for target `all'
I guess this is what you're looking for?
$ cat Makefile2
all:
for i in .bashrc .emacs; do \
echo $$i; \
if test -f $$i; then \
(cp $$i /tmp/a/b/c && ls /tmp/a/b/c) || true; \
fi; \
done
$ make -f Makefile2
for i in .bashrc .emacs; do \
echo $i; \
if test -f $i; then \
(cp $i /tmp/a/b/c && ls /tmp/a/b/c) || true; \
fi; \
done
.bashrc
cp: cannot create regular file `/tmp/a/b/c': No such file or directory
.emacs
cp: cannot create regular file `/tmp/a/b/c': No such file or directory
$ echo $?
0