From f28d694879239d5d9c319185a278236d317a49b6 Mon Sep 17 00:00:00 2001 From: zachir Date: Sat, 30 Aug 2025 01:09:18 -0500 Subject: Make sh scrips POSIX compliant Using shellcheck, I went through all of them to make them standards compliant. I also tested as many as I could. --- tagimg | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tagimg') diff --git a/tagimg b/tagimg index 109e7bd..c8bee44 100755 --- a/tagimg +++ b/tagimg @@ -1,7 +1,7 @@ #!/bin/sh # check for flags -for i in $@; do +for i; do case "$i" in "-"*) unset DIRSFLAG LOCALFLAG ;; @@ -9,7 +9,7 @@ for i in $@; do [ -n "$DIRSFLAG" ] && unset LOCALFLAG [ -n "$LOCALFLAG" ] && unset DIRSFLAG [ -n "$THUMBFLAG" ] && THUMBNAIL="$i" && unset THUMBFLAG - [ -n "$FILEFLAG" ] && FILENAME="$(printf "$i\n$FILENAME" | paste -s -d'|')" && unset FILEFLAG + [ -n "$FILEFLAG" ] && FILENAME="$(printf "$i\n%s" "$FILENAME" | paste -s -d'|')" && unset FILEFLAG case "$i" in "-d") DIRSFLAG="y" @@ -33,11 +33,11 @@ done [ -z "$THUMBNAIL" ] && THUMBNAIL="thumb.jpg" if [ -n "$DIRSFLAG" ]; then - ls | while read i; do + find ./* | while read -r i; do [ ! -d "$i" ] && continue - ls "$i"| while read j; do + find "$i"/* | while read -r j; do [ ! -d "$j" ] && continue - ls "$i/$j" | while read k; do + find "$i/$j"/* | while read -r k; do [ ! -f "$k" ] && continue case "$k" in *.mp3 | *.flac ) @@ -50,7 +50,7 @@ if [ -n "$DIRSFLAG" ]; then elif [ -n "$LOCALFLAG" ]; then [ -z "$FILENAME" ] && exit 1 IFS='|' - for i in "$FILENAME"; do + for i in $FILENAME; do mid3v2 -p "$THUMBNAIL" "$i" done unset IFS -- cgit v1.2.3