commit 6de6c32d0d9b7ecf44e275a3ed24be0c71098d64
parent 66df8cd9ed1a9539af59eaf07dfce647b7ad2fe5
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Mon, 28 Sep 2020 15:30:42 -0700
Use warn function
note that it does not explicitly include the util module.
Diffstat:
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/aliases/.config/aliases/mpc b/aliases/.config/aliases/mpc
@@ -10,8 +10,12 @@ alias ms="m search"
alias mP="m searchplay any"
alias ma="m add"
-# get mpd settings
-mpdconfig() { eval echo `grep $1 $XDG_CONFIG_HOME/mpd/mpd.conf | sed -E 's/.*"(.*)\"/\1/g'` ;}
+# return mpd setting (must be of the regex format: `^setting ['"]?value["']?'
+mpdconfig() {
+ awk -F"[[:space:]\"']+" -vreg=${1:?No expression} \
+ 'match($1, reg) > 0 { sub("^~", ENVIRON["HOME"], $2); print $2; ++c } END { exit (c - 1) }' \
+ $XDG_CONFIG_HOME/mpd/mpd.conf
+}
# grep mpc playlists
mgrep() { grep -h $@ `mpdconfig playlist_directory`/* | sort -u ;}
@@ -26,7 +30,7 @@ mato() {
if [ $? -eq 1 ]; then
echo "$track" >> $dir/$1.m3u
else
- echo "warning: '$1': Already contains track." 1>&2
+ warn "'$1': Already contains this track."
fi
shift
done