jcupitt/libvips — pull request #38 by sepastian (2012-11-13 14:19:18+00:00)
Title: Show 'usage', if wrong number of arguments has been given

Currently, the `tools/batch_*` scripts will print a rather cryptic message, if the number of arguments on the command line is wrong. For instance, `batch_crop` expects at least 5 arguments, invoking the command with fewer than 5 arguments will result in:

$ batch_crop
`/usr/bin/batch_crop: 19: shift: can't shift that many`

This is because the batch scripts are invoking `shift` before making sure that enough arguments have been specified.

This pull request fixes that by moving the invocation of `shift` down, until after checking for the right number of arguments. Instead of failing on `shift`, the usage message will now be shown, if a wrong number of arguments has been given.