From 6790aad25e53fd17093d2576a495191fdee4379f Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 17 Jun 2023 02:30:12 -0400 Subject: sbopkglint: spaces in filenames WIP #7. --- sbopkglint.d/50-icons.t.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'sbopkglint.d') diff --git a/sbopkglint.d/50-icons.t.sh b/sbopkglint.d/50-icons.t.sh index 1398cff..1f1f032 100644 --- a/sbopkglint.d/50-icons.t.sh +++ b/sbopkglint.d/50-icons.t.sh @@ -29,8 +29,10 @@ check_mime() { check_image() { local f="$1" local size - local bn="$( basename $f )" - local ext="$( echo $bn | sed 's,.*\.\([^.]*\)$,\1,' )" + local actualsize + local mime + local bn="$( basename "$f" )" + local ext="$( echo "$bn" | sed 's,.*\.\([^.]*\)$,\1,' )" [ "$ext" = "$f" ] && ext="" [ "$bn" = "theme" -o "$bn" = "icon-theme.cache" -o "$bn" = "index.theme" ] && return @@ -38,20 +40,20 @@ check_image() { mime="$( file -L -z -b --mime-type "$f" )" case "$mime" in image/*) ;; # OK - *) nonimages+="$f " ; return ;; + *) ( echo -n "[$mime]: " ; ls -bld "$f" ) >> .nonimages.$$; return ;; esac # it's not real clear to me whether .bmp or .ico should be allowed # as icons. for now, just check the mime types. case "$ext" in ""|".") badextensions+="$f " ;; - PNG|png) check_mime $f $mime image/png ;; - GIF|gif) check_mime $f $mime image/gif ;; - JPG|jpg|JPEG|jpeg) check_mime $f $mime image/jpeg ;; - XPM|xpm) check_mime $f $mime image/x-xpmi ;; - SVG|svg|SVGZ|svgz) check_mime $f $mime image/svg+xml ;; - BMP|bmp) check_mime $f $mime image/bmp ;; - ICO|ico) check_mime $f $mime image/vnd.microsoft.icon ;; + PNG|png) check_mime "$f" "$mime" image/png ;; + GIF|gif) check_mime "$f" "$mime" image/gif ;; + JPG|jpg|JPEG|jpeg) check_mime "$f" "$mime" image/jpeg ;; + XPM|xpm) check_mime "$f" "$mime" image/x-xpmi ;; + SVG|svg|SVGZ|svgz) check_mime "$f" "$mime" image/svg+xml ;; + BMP|bmp) check_mime "$f" "$mime" image/bmp ;; + ICO|ico) check_mime "$f" "$mime" image/vnd.microsoft.icon ;; esac # extract e.g. 64x64 or 128x128 from the path to the file. @@ -71,11 +73,11 @@ check_image() { for icondir in usr/share/pixmaps usr/share/icons/hicolor; do if [ -d "$icondir" ]; then - files="$( find -L "$icondir" -type f )" - for i in $files; do - check_image $i + find -L "$icondir" -type f | while read i; do + check_image "$i" done fi done -[ "$nonimages" != "" ] && warn "non-image files in icon dirs:" && ls -ld $nonimages +[ -s .nonimages.$$ ] && warn "non-image files in icon dirs:" && cat .nonimages.$$ +rm -f .nonimages.$$ -- cgit v1.2.3