Skip to content

Commit

Permalink
shellcheck: avoid unnecessary echo
Browse files Browse the repository at this point in the history
Shellcheck advises:

  SC2005: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'.

The extra echo was added in 9bd52f as a workaround for `wc' in OSX,
which printed extra whitespace before the character count. Fix this
issue in a different way by piping the `wc' output through `awk'.

This also means that we no longer use the suggested workaround, so
remove the dangling acknowledgement.
  • Loading branch information
aklomp committed May 22, 2022
1 parent d5f605a commit e37a640
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 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`.
4 changes: 2 additions & 2 deletions shrinkpdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ check_smaller ()
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 Down

0 comments on commit e37a640

Please sign in to comment.