From c80ebccbd25b8fbad1b4e3079daa765bacfdbcbd Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Fri, 19 Jul 2019 10:37:30 +0200 Subject: [PATCH] Fix 2nd argument not valid due to image path --- README.md | 2 +- optimize.sh | 40 +++++++++++++--------------------------- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index c2d84af..f5ed404 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![img-optimize](https://raw.githubusercontent.com/VirtuBox/img-optimize/master/img-optimize.png) -![GitHub](https://img.shields.io/github/license/VirtuBox/img-optimize.svg) ![GitHub release](https://img.shields.io/github/release/VirtuBox/img-optimize.svg) ![GitHub last commit](https://img.shields.io/github/last-commit/VirtuBox/img-optimize.svg) ![Github stars](https://img.shields.io/github/stars/VirtuBox/img-optimize.svg) +[![Travis (.org)](https://img.shields.io/travis/VirtuBox/img-optimize.svg)](https://travis-ci.org/VirtuBox/img-optimize) ![GitHub](https://img.shields.io/github/license/VirtuBox/img-optimize.svg) ![GitHub release](https://img.shields.io/github/release/VirtuBox/img-optimize.svg) ![GitHub last commit](https://img.shields.io/github/last-commit/VirtuBox/img-optimize.svg) ![Github stars](https://img.shields.io/github/stars/VirtuBox/img-optimize.svg) ## Prerequisite diff --git a/optimize.sh b/optimize.sh index d261f23..40b23f9 100755 --- a/optimize.sh +++ b/optimize.sh @@ -23,20 +23,21 @@ _help() { echo "Usage: img-optimize [options] " echo "If images path isn't defined, img-optimize will use the current directory " echo " Options:" - echo " --jpg ..... optimize all jpg images" - echo " --png ..... optimize all png images" - echo " --webp ..... convert all images in webp" - echo " --nowebp ..... optimize all png & jpg images" - echo " --all ..... optimize all images (png + jpg + webp)" + echo " --jpg ..... optimize all jpg images" + echo " --png ..... optimize all png images" + echo " --webp ..... convert all images in webp" + echo " --nowebp ..... optimize all png & jpg images" + echo " --all ..... optimize all images (png + jpg + webp)" echo " -i, --interactive ..... run img-optimize in interactive mode" echo " -q, --quiet ..... run image optimization quietly" + echo " --path ..... define images path" echo " Other options :" echo " -h, --help, help ... displays this help information" echo " --cmin [+|-] ... File's status was last changed n minutes ago." echo " act find cmin argument (+n : greater than n, -n : less than n, n : exactly n)" echo "Examples:" echo " optimize all jpg images in /var/www/images" - echo " img-optimize --jpg /var/www/images" + echo " img-optimize --jpg --path /var/www/images" echo "" return 0 } @@ -54,42 +55,22 @@ else case "$1" in --jpg) JPG_OPTIMIZATION="y" - if [ "$2" ]; then - IMG_PATH=$2 - shift - fi ;; --png) PNG_OPTIMIZATION="y" - if [ "$2" ]; then - IMG_PATH=$2 - shift - fi ;; --nowebp) JPG_OPTIMIZATION="y" PNG_OPTIMIZATION="y" WEBP_OPTIMIZATION="n" - if [ "$2" ]; then - IMG_PATH=$2 - shift - fi ;; --webp) WEBP_OPTIMIZATION="y" - if [ "$2" ]; then - IMG_PATH=$2 - shift - fi ;; --all) PNG_OPTIMIZATION="y" JPG_OPTIMIZATION="y" WEBP_OPTIMIZATION="y" - if [ "$2" ]; then - IMG_PATH=$2 - shift - fi ;; -i | --interactive) INTERACTIVE_MODE="1" @@ -102,7 +83,12 @@ else --cmin) if [ "$2" ]; then FIND_ARGS+="-cmin $2" - shift + shift + fi + ;; + --path) + if [ "$2" ]; then + IMG_PATH="$2" fi ;; -h | --help | help)