source-foundry / ttfautohint-build

Build ttfautohint from source on Linux and macOS platforms
MIT License
27 stars 12 forks source link

Ensure script fails if any of its commands fails #40

Open CodingMarkus opened 2 years ago

CodingMarkus commented 2 years ago

Currently the script misses set -e. As a result, if one of the commands terminate with a non-zero exit code, indicating failure, the script just continues.

E.g. a past version of the script failed to apply a patch using patch -p1 -N -r - < "$i" but that didn't cause the script to terminate, it just continued and the build did not contain the patch. I would expect the same thing to happen if make fails, in which case it will just call make install anyway, which will fail as well and then just continue to the next build.

Also with set -e, you can forgo constructs like this cd "$FREETYPE" || exit 1, as if the cd fails, its exit code won't be zero and the script will terminate automatically.

set -e is a POSIX flag, all shells do support it. Without that, plenty of failures can go unnoticed and lead to strange results and hard to trace bugs.

If you still want to allow a command to fail, this is possible using do_something || true; if do_something fails, the script will not exit and just ignore that fact. Currently all your calls are like that because of the missing flag.