Add xargs flag --no-run-if-empty

This commit is contained in:
VirtuBox 2019-07-12 14:07:39 +02:00
parent 9b152bb6c8
commit 94b9c21492
Signed by: virtubox
GPG Key ID: 22EB296C97BAD476
2 changed files with 7 additions and 6 deletions

View File

@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Added
- quiet mode
- option --no-run-if-empty added to xargs
### Changed

View File

@ -156,9 +156,9 @@ if [ "$JPG_OPTIMIZATION" = "y" ]; then
echo -ne ' jpg optimization [..]\r'
cd "$IMG_PATH" || exit 1
if [ "$QUIET_MODE" = "1" ]; then
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) -print0 | xargs -0 jpegoptim -q --preserve --strip-all -m82
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) -print0 | xargs -r -0 jpegoptim -q --preserve --strip-all -m82
else
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) -print0 | xargs -0 jpegoptim --preserve --strip-all -m82
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) -print0 | xargs -r -0 jpegoptim --preserve --strip-all -m82
fi
echo -ne " jpg optimization [${CGREEN}OK${CEND}]\\r"
@ -174,9 +174,9 @@ if [ "$PNG_OPTIMIZATION" = "y" ]; then
echo -ne ' png optimization [..]\r'
cd "$IMG_PATH" || exit 1
if [ "$QUIET_MODE" = "1" ]; then
find . -type f -iname '*.png' -print0 | xargs -0 optipng -quiet -o7 -strip all
find . -type f -iname '*.png' -print0 | xargs -r -0 optipng -quiet -o7 -strip all
else
find . -type f -iname '*.png' -print0 | xargs -0 optipng -quiet -o7 -strip all
find . -type f -iname '*.png' -print0 | xargs -r -0 optipng -quiet -o7 -strip all
fi
echo -ne " png optimization [${CGREEN}OK${CEND}]\\r"
@ -191,10 +191,10 @@ if [ "$WEBP_OPTIMIZATION" = "y" ]; then
echo -ne ' png to webp conversion [..]\r'
cd "$IMG_PATH" || exit 1
if [ "$QUIET_MODE" = "1" ]; then
find . -type f -iname "*.png" -print0 | xargs -0 -I {} \
find . -type f -iname "*.png" -print0 | xargs -r -0 -I {} \
bash -c '[ ! -f "{}.webp" ] && { cwebp -quiet -z 9 -mt "{}" -o "{}.webp"; }'
else
find . -type f -iname "*.png" -print0 | xargs -0 -I {} \
find . -type f -iname "*.png" -print0 | xargs -r -0 -I {} \
bash -c '[ ! -f "{}.webp" ] && { cwebp -z 9 -mt "{}" -o "{}.webp"; }'
fi