diff options
author | Florian Pritz <bluewind@xinu.at> | 2016-04-02 19:41:17 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2016-04-02 19:41:17 +0200 |
commit | 7c04038cb1c56a43d40df52213c7eb4be375279c (patch) | |
tree | b9549f004d844ede41c9b7c5c70339803ee8ebb5 /pdfmerge | |
parent | 355f8c8457863352412c730ba634f431b23091b7 (diff) | |
download | bin-7c04038cb1c56a43d40df52213c7eb4be375279c.tar.gz bin-7c04038cb1c56a43d40df52213c7eb4be375279c.tar.xz |
pdfmerge: Don't overwrite files
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'pdfmerge')
-rwxr-xr-x | pdfmerge | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -3,9 +3,17 @@ args=$(($# - 1)) +infiles=(${@:1:args}) +outfile=${!#} + if [[ $# = 0 ]] || [[ $args = 0 ]]; then echo "usage: ${0##*/} input.pdf [input2.pdf ..] output.pdf" exit 0 fi -gs -dNOPAUSE -dQUIET -dBATCH -sOutputFile=${!#} -sDEVICE=pdfwrite "${@:1:$args}" +if [[ -e $outfile ]]; then + printf "Error: Output file '%s' already exists!\n" "$outfile" >&2 + exit 1 +fi + +gs -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$outfile" -sDEVICE=pdfwrite "${infiles[@]}" |