Use double-quotes to avoid word-splitting.

This commit is contained in:
Nicolás A. Ortega Froysa 2025-01-17 14:38:50 +01:00
parent d2fb70ed9f
commit 27f4e2316f

View File

@ -47,7 +47,7 @@ new_link() {
# NOTE: I chose þ because never in a million years will that
# character be in the title of a lofi video stream.
IFS="þ" read -r -a streams <<< $results
IFS="þ" read -r -a streams <<< "$results"
echo "Streams:"
local id=1
@ -66,7 +66,7 @@ new_link() {
link=${streams[$opt]}
link=${link//\" \"*/}
link=${link//*\"/}
echo $link > $link_file
echo "$link" > "$link_file"
}
# argument parsing
@ -86,7 +86,7 @@ elif [ "$#" -eq "2" ]
then
if [ "$1" = "set" ]
then
echo "$2" > $link_file
echo "$2" > "$link_file"
exit 0
else
echo "Unknown command '$1 $2'. Run 'play-lofi help' for a list of commands."
@ -112,10 +112,10 @@ then
echo "New link file created."
fi
link=$(cat $link_file)
link=$(cat "$link_file")
# check if video is available
output=$(curl -s $link | grep "This video is unavailable.")
output=$(curl -s "$link" | grep "This video is unavailable.")
if [ -n "$output" ]
then
echo "The stream link '$link' is unavailable."
@ -129,4 +129,4 @@ then
echo "New link saved."
fi
mpv --no-video --msg-level=ffmpeg=no $link
mpv --no-video --msg-level=ffmpeg=no "$link"