Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make aborting because zip exits with status 12

Tags:

unix

makefile

zip

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?

like image 223
Sabrina S Avatar asked Oct 08 '13 15:10

Sabrina S


2 Answers

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.)

like image 123
Alexander L. Belikoff Avatar answered Oct 17 '22 07:10

Alexander L. Belikoff


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 ]
like image 22
user3137335 Avatar answered Oct 17 '22 05:10

user3137335