diff --git a/build/image-optimization.sh b/build/image-optimization.sh index 65a5bb46362f40957b7f124fe9d85bb38afca501..bf825c96cc6f55600459c2e7a42a6c9393e21ae4 100755 --- a/build/image-optimization.sh +++ b/build/image-optimization.sh @@ -8,7 +8,7 @@ function recursive_optimize_images() { jpegoptim --strip-all *.jpg; # Optimize all SVGs - for svg in `ls *.svg`; + for svg in *.svg; do mv $svg $svg.opttmp; scour --create-groups \ @@ -26,10 +26,12 @@ function recursive_optimize_images() { rm *.opttmp # Check all subfolders - for dir in `ls -d */`; + for dir in */ do - recursive_optimize_images $dir; - cd ..; + if [[ -d "$DIR" ]]; then + recursive_optimize_images "$dir" + cd .. + fi done; }