From 7080db5c1d9ae6cb0d4a799dcf8970601a2c6722 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 3 Jul 2026 14:32:08 +0200 Subject: [PATCH] fix shellcheck issues vorbis.sh --- libs/vorbis.sh | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/libs/vorbis.sh b/libs/vorbis.sh index 98af34c..b538092 100644 --- a/libs/vorbis.sh +++ b/libs/vorbis.sh @@ -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 "{}" -- 2.47.3