Skip to content

Commit

Permalink
#2: fix issues raised by Shellcheck
Browse files Browse the repository at this point in the history
Fix the issues found by `shellcheck' after issue #1 added it as a CI
job.

Closes #2.
  • Loading branch information
aklomp committed May 22, 2022
2 parents f455dd6 + e37a640 commit ffe5ca8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,3 @@ The script is licensed under the

I didn't invent the wheel, just packaged it nicely. All credits go to the
[Ghostscript](http://www.ghostscript.com) team.

Many thanks to Dr. Alun J. Carr for fixing a portability issue on Mac OS X
regarding leading whitespace in the output of `wc`.
16 changes: 8 additions & 8 deletions shrinkpdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ shrink ()
-dSubsetFonts=true \
-dAutoRotatePages=/None \
-dColorImageDownsampleType=/Bicubic \
-dColorImageResolution=$3 \
-dColorImageResolution="$3" \
-dGrayImageDownsampleType=/Bicubic \
-dGrayImageResolution=$3 \
-dGrayImageResolution="$3" \
-dMonoImageDownsampleType=/Subsample \
-dMonoImageResolution=$3 \
-dMonoImageResolution="$3" \
-sOutputFile="$2" \
"$1"
}
Expand All @@ -54,11 +54,11 @@ check_smaller ()
{
# If $1 and $2 are regular files, we can compare file sizes to
# see if we succeeded in shrinking. If not, we copy $1 over $2:
if [ ! -f "$1" -o ! -f "$2" ]; then
if [ ! -f "$1" ] || [ ! -f "$2" ]; then
return 0;
fi
ISIZE="$(echo $(wc -c "$1") | cut -f1 -d\ )"
OSIZE="$(echo $(wc -c "$2") | cut -f1 -d\ )"
ISIZE="$(wc -c "$1" | awk '{ print $1 }')"
OSIZE="$(wc -c "$2" | awk '{ print $1 }')"
if [ "$ISIZE" -lt "$OSIZE" ]; then
echo "Input smaller than output, doing straight copy" >&2
cp "$1" "$2"
Expand All @@ -81,14 +81,14 @@ if [ -z "$IFILE" ]; then
fi

# Output filename defaults to "-" (stdout) unless given:
if [ ! -z "$2" ]; then
if [ -n "$2" ]; then
OFILE="$2"
else
OFILE="-"
fi

# Output resolution defaults to 72 unless given:
if [ ! -z "$3" ]; then
if [ -n "$3" ]; then
res="$3"
else
res="72"
Expand Down

0 comments on commit ffe5ca8

Please sign in to comment.