Merge pull request 'add_linter' (#5) from add_linter into master
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: #5
This commit is contained in:
otthorn 2021-02-19 01:20:10 +01:00
commit b9a354813d
3 changed files with 22 additions and 10 deletions

11
.drone.yml Normal file
View file

@ -0,0 +1,11 @@
---
kind: pipeline
type: docker
name: lint
steps:
- name: ShellCheck
image: koalaman/shellcheck-alpine:v0.7.1
commands:
- shellcheck -e SC2181 pdf-optimize
...

View file

@ -1,4 +1,5 @@
# pdf-optimize # pdf-optimize
[![Build Status](https://drone.auro.re/api/badges/otthorn/pdf-optimize/status.svg)](https://drone.auro.re/otthorn/pdf-optimize)
pdf-optimize is a simple script to optimize pdf using ghostscript. pdf-optimize is a simple script to optimize pdf using ghostscript.
You need to have ghoscript installed on your machine. You need to have ghoscript installed on your machine.

View file

@ -78,7 +78,7 @@ function arg_parse
function yes_or_no function yes_or_no
{ {
read -p "$* [y/N]: " ans read -pr "$* [y/N]: " ans
case "$ans" in case "$ans" in
[yY] | [yY]es ) return 0;; [yY] | [yY]es ) return 0;;
* ) echo "Aborting"; return 1;; * ) echo "Aborting"; return 1;;
@ -103,8 +103,8 @@ ${bold}$output_path${normal}."
-dNOPAUSE \ -dNOPAUSE \
-dQUIET \ -dQUIET \
-dBATCH \ -dBATCH \
-sOutputFile=$output_path \ -sOutputFile="$output_path" \
$input_path "$input_path"
else else
echo "input_path=$input_path"; echo "input_path=$input_path";
echo "output_path=$output_path"; echo "output_path=$output_path";
@ -117,8 +117,8 @@ ${bold}$output_path${normal}."
-dPDFSETTINGS=/prepress \ -dPDFSETTINGS=/prepress \
-dNOPAUSE \ -dNOPAUSE \
-dBATCH \ -dBATCH \
-sOutputFile=$output_path \ -sOutputFile="$output_path" \
$input_path "$input_path"
fi fi
# catching errors # catching errors
@ -136,11 +136,11 @@ ${bold}$output_path${normal}."
function compute_compression function compute_compression
{ {
input_size=`du "$input_path" | cut -f1` input_size=$(du "$input_path" | cut -f1)
output_size=`du "$output_path" | cut -f1` output_size=$(du "$output_path" | cut -f1)
percentage=`echo "scale=1;$output_size / $input_size * 100" | bc -l` percentage=$(echo "scale=1;$output_size / $input_size * 100" | bc -l)
input_size_h=`du -h "$input_path" | cut -f1` input_size_h=$(du -h "$input_path" | cut -f1)
output_size_h=`du -h "$output_path" | cut -f1` output_size_h=$(du -h "$output_path" | cut -f1)
echo "Size reduced from ${bold}$input_size_h${normal} to \ echo "Size reduced from ${bold}$input_size_h${normal} to \
${bold}$output_size_h${normal} [$percentage %]" ${bold}$output_size_h${normal} [$percentage %]"