From 25b12e53985f289ce0f92b32a3b3ad6c69a4247b Mon Sep 17 00:00:00 2001
From: Salt <rehashedsalt@cock.li>
Date: Thu, 26 Sep 2019 16:38:21 -0500
Subject: [PATCH] Minor bugfixes, avoid crashing unexpectedly

---
 ptgdp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/ptgdp b/ptgdp
index 5dc51f7..614b55c 100755
--- a/ptgdp
+++ b/ptgdp
@@ -24,7 +24,7 @@ declare -A _config=(
 	[ytdl_args]="--geo-bypass"
 )
 declare _optconfigfile="${XDG_CONFIG_HOME:-$HOME/.config}/${_name}.conf"
-declare -i _optautoplay
+declare -i _optautoplay=0
 declare -i _opthelp
 declare -i _optverbose
 # Working variables
@@ -57,7 +57,7 @@ error() {
 has() {
 	# Parse out all arguments and try to find them in path
 	# If an argument cannot be found, set _return and fail
-	for prog in $@; do
+	for prog in "$@"; do
 		if ! command -v "$prog" > /dev/null 2>&1; then
 			_return="$prog"
 			return 1
@@ -128,9 +128,11 @@ queuesong() {
 	case $_returnstatus in
 		cache)
 			log "Using cached song \"$1\"" 1
+			log " $_return" 2
 			;;
 		*)
-			log "Downloaded song \"$1\"" 1
+			log "Downloaded song \"$1\""
+			log " $_return" 2
 			;;
 	esac
 	_queue+=("$_return")
@@ -205,7 +207,9 @@ backend-execqueue() {
 	for song in "${_queue[@]}"; do
 		backend-enqueue "$song"
 	done
-	[ "$_optautoplay" != "0" ] && backend-play
+	if [ "$_optautoplay" != "0" ]; then
+		backend-play
+	fi
 }
 
 # Core program functions