about summary refs log tree commit diff stats
path: root/common
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-12-01 12:38:24 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-12-01 12:38:24 +0100
commita43b3fba1342dea253aa1b9b8c2b07b17fe2fcd9 (patch)
tree1b040a6cce0ebace7980d452dacb74fa87370f7a /common
parentfix(common/scripts/latex/build.sh): Rewrite `find` invocations with `fd` (diff)
downloadflake-templates-a43b3fba1342dea253aa1b9b8c2b07b17fe2fcd9.tar.gz
flake-templates-a43b3fba1342dea253aa1b9b8c2b07b17fe2fcd9.zip
fix(common/scripts/optimize_images.sh): Generate extension only on basename
This avoids taking the "extension" of a directory as a extension
(e.g. `addons.d/file.ext`, would produce an extension of `d/file.ext`
 instead of the expected `ext`)
Diffstat (limited to 'common')
-rwxr-xr-xcommon/scripts/optimize_images.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/common/scripts/optimize_images.sh b/common/scripts/optimize_images.sh
index 0f48e4b..444405d 100755
--- a/common/scripts/optimize_images.sh
+++ b/common/scripts/optimize_images.sh
@@ -25,7 +25,8 @@ find_files_by_extension() {
     tmp="$(mktemp)"
 
     git ls-files --cached --modified --other --exclude-standard --deduplicate | while IFS= read -r file; do
-        extension="${file#*.}"
+        file_basename="$(basename "$file")"
+        extension="${file_basename#*.}"
         if [ "$extension" = "$wanted_extension" ]; then
             echo "$file"
         else
@@ -90,7 +91,7 @@ optimize_files() {
     TOTAL_SAVED_INNER=0
 
     while IFS= read -r f; do
-        printf "%-2s/${COUNT} $f ... " "$I"
+        printf "%s/${COUNT} $f ... " "$I"
 
         SIZE="$(size_of "$f")"