]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
fix shellcheck issues vorbis.sh
authorBastian Dehn <hhaalo@arcor.de>
Fri, 3 Jul 2026 12:32:08 +0000 (14:32 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 3 Jul 2026 12:57:22 +0000 (14:57 +0200)
libs/vorbis.sh

index 98af34c9bc47a91bd5d0de6ffe3d7e4e11871de0..b538092549ba9f8577e0143506e6f143f83afc58 100644 (file)
@@ -1,17 +1,19 @@
+#!/bin/bash
+
 read_flac_to_ogg_tags()
 {
        local inputfile="$1"
        local outputfile="$2"
        local coverfile="${inputfile%/*}/cover.txt"
 
-       metaflac --export-tags-to=- $inputfile \
-               | vorbiscomment --commentfile - --write $outputfile
+       metaflac --export-tags-to=- "$inputfile" \
+               | vorbiscomment --commentfile - --write "$outputfile"
 
-       [ -f $coverfile ] \
+       [ -f "$coverfile" ] \
                || return 0
 
-       echo "METADATA_BLOCK_PICTURE=$(base64 --wrap 0 $coverfile)" \
-               | vorbiscomment --commentfile - --raw --append $outputfile
+       echo "METADATA_BLOCK_PICTURE=$(base64 --wrap 0 "$coverfile")" \
+               | vorbiscomment --commentfile - --raw --append "$outputfile"
 }
 
 encoding_flac_to_ogg()
@@ -38,10 +40,11 @@ write_hex_to_file()
 {
        local number="$1"
        local outputfile="$2"
-       local hex_number=$(printf "%08x" "$number")
+       local hex_number=
+       hex_number=$(printf "%08x" "$number")
 
        for i in {0..6..2}; do
-               printf "%b" "\x${hex_number:$i:2}" >> $outputfile
+               printf "%b" "\x${hex_number:$i:2}" >> "$outputfile"
        done
 }
 
@@ -49,13 +52,15 @@ cover_to_metadata()
 {
        local inputfile="$1"
        local outputfile="${inputfile/.jpg/.txt}"
-       local filesize=$(cat $inputfile | wc -c)
+       local filesize=
+       filesize=$(wc --chars "$inputfile")
+       filesize=${filesize/ */}
 
        # picture typ (jpg)
        write_hex_to_file "3" "$outputfile"
        # mime type (image/jpeg)
        write_hex_to_file "10" "$outputfile"
-       printf "%s" "image/jpeg" >> $outputfile
+       printf "%s" "image/jpeg" >> "$outputfile"
        # description length (zero)
        write_hex_to_file "0" "$outputfile"
        # width (zero)
@@ -68,7 +73,7 @@ cover_to_metadata()
        write_hex_to_file "0" "$outputfile"
        # file size
        write_hex_to_file "$filesize" "$outputfile"
-       cat $inputfile >> $outputfile
+       cat "$inputfile" >> "$outputfile"
 }
 
 convert_flac_to_ogg()
@@ -80,11 +85,11 @@ convert_flac_to_ogg()
        export -f read_flac_to_ogg_tags
        export -f cover_to_metadata
        export -f write_hex_to_file
-       find $workdir -name '*.jpg' \
+       find "$workdir" -name '*.jpg' \
                | sort \
                | parallel --will-cite --ungroup \
                cover_to_metadata {}
-       find $workdir -name '*.flac' \
+       find "$workdir" -name '*.flac' \
                | sort \
                | parallel --will-cite --ungroup --eta --progress \
                flac_to_vorbis "{}"