Minor bugfixes, avoid crashing unexpectedly

This commit is contained in:
Salt 2019-09-26 16:38:21 -05:00
parent f35f8867f6
commit 25b12e5398

12
ptgdp
View File

@ -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