Skip to content

Commit d6bbc33

Browse files
committed
Make reflac more resiliant against odd file names.
Directories or files that begin with a hyphen could throw off the parsing of a lot of the internal commands the program calls upon. This should fix that.
1 parent 547aa2a commit d6bbc33

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

reflac

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@ recompress()
4444
fi
4545

4646
metaflac --no-utf8-convert \
47-
--export-tags-to="$(basename "$flac" flac)tag" "$flac"
47+
--export-tags-to="$(basename -s flac -- "$flac")tag" -- "$flac"
4848

4949
if [ $VERBOSE -gt 1 ]; then
50-
flac --delete-input-file -d "$flac"
51-
flac --delete-input-file -$FLAC_LEVEL \
52-
"$(basename "$flac" flac)wav"
50+
flac --delete-input-file -d -- "$flac"
51+
flac --delete-input-file -$FLAC_LEVEL -- \
52+
"$(basename -s flac -- "$flac")wav"
5353
else
54-
flac -s --delete-input-file -d "$flac"
55-
flac -s --delete-input-file -$FLAC_LEVEL \
56-
"$(basename "$flac" flac)wav"
54+
flac -s --delete-input-file -d -- "$flac"
55+
flac -s --delete-input-file -$FLAC_LEVEL -- \
56+
"$(basename -s flac -- "$flac")wav"
5757
fi
5858

5959
metaflac --no-utf8-convert \
60-
--import-tags-from="$(basename "$flac" flac)tag" "$flac"
61-
rm -f "$(basename "$flac" flac)tag"
60+
--import-tags-from="$(basename -s flac -- "$flac")tag" -- "$flac"
61+
rm -f -- "$(basename -s flac -- "$flac")tag"
6262
done
6363
}
6464

@@ -85,8 +85,8 @@ while true ; do
8585
done
8686

8787
for dir do
88-
cd "$dir" || exit 1
89-
if [ $VERBOSE -gt 0 ]; then echo "Entering $dir"; fi
88+
cd -- "$dir" || exit 1
89+
if [ $VERBOSE -gt 0 ]; then echo "$dir"; fi
9090
recompress
9191
cd "$CWD"
9292
done

0 commit comments

Comments
 (0)