make
is halting and reporting an error code of 12 after attempting to zip -u
some files.
The error code 12 is actually an exit status from zip which indicates that it has "nothing to do."
I don't understand why this is a non-zero exit status. Wouldn't it be more appropriate to just let zip quietly do nothing? It doesn't seem like an actual problem if zip has nothing to do.
I could suppress it: tell make
to ignore non-zero exit status from zip by calling -zip -u
. But the problem with that approach is that 12 is the only exit status I want to ignore. All of the others indicate actual problems that would cause me to want to abort make
.
Maybe I could set a variable equal to the output from echo $?
and then test for 0 or 12 but it seems klodgy to do this after every single zip
statement in the .mk file.
Is there an elegant way to handle this?
Err... As a quick and dirty solution, you can use a shell wrapper:
#!/bin/ksh
zip "$@"
rc=$?
if [[ rc -eq 12 ]]; then
exit 0
fi
exit $rc
Alternatively, you can do almost the same inline in Makefile but it will look somewhat ugly (will have to be a shell one-liner with duplicate $
signs etc.)
Something like this sounds simpler to me. It returns an error in make if the error code is non-zero and different of 12.
target:
zip -uj file.zip file.csv || [ $$? -eq 12 ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With