mirror of
https://codeberg.org/h3xx/optipdf
synced 2024-08-15 00:03:23 +00:00
Check qpdf is available before starting
This commit is contained in:
parent
7da19cfaf3
commit
44308e890f
1 changed files with 19 additions and 0 deletions
19
optipdf
19
optipdf
|
@ -105,6 +105,22 @@ if [[ ${#FILES[@]} -eq 0 ]]; then
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
check_required_binaries() {
|
||||||
|
local BIN MISSING=()
|
||||||
|
for BIN; do
|
||||||
|
if ! type -t "$BIN" &>/dev/null; then
|
||||||
|
MISSING+=("$BIN")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ ${#MISSING[@]} -gt 0 ]]; then
|
||||||
|
printf 'Error: You are missing required programs:\n' >&2
|
||||||
|
for BIN in "${MISSING[@]}"; do
|
||||||
|
printf -- '- %s\n' "$BIN" >&2
|
||||||
|
done
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
file_size() {
|
file_size() {
|
||||||
stat \
|
stat \
|
||||||
--format='%s' \
|
--format='%s' \
|
||||||
|
@ -200,6 +216,9 @@ use_smaller() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_required_binaries \
|
||||||
|
qpdf
|
||||||
|
|
||||||
QPDF_ARGS=(
|
QPDF_ARGS=(
|
||||||
--compression-level=9
|
--compression-level=9
|
||||||
--deterministic-id
|
--deterministic-id
|
||||||
|
|
Loading…
Reference in a new issue