config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit fdc97bb3aa862d2b4a84cd90935a398ee3a29008
parent f21c7df2f2fc38392846793e2dad7407273d4522
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Sat,  5 Dec 2020 15:56:55 -0800

Fix bug and logic in mato script

Fix bug by setting `ifs` to carrage return.

To be more logicaly sound rename `isduplicate` to `errdup`.

Remove test for file existence as rc(1) will do it.

Diffstat:
Mmodules/scripts/.local/bin/mato | 14++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/modules/scripts/.local/bin/mato b/modules/scripts/.local/bin/mato @@ -5,11 +5,13 @@ #! playlist_directory setting, unless it's a duplicate in which case #! added and a warning is printed to the standard error. +ifs = ' +' progname = `{ basename $0 } fn warn { printf '%s: ' $progname; printf $* } fn err { warn $*; exit 1 } -fn isduplicate { +fn errdup { awk '-vtrack='^$1 \ 'length($0) == length(track) && index(track, $0) > 0 { exit 1 @@ -26,13 +28,9 @@ track = `{ mpc current -f '%file%' } for (m3u in $*) { file = $dir/$m3u.m3u; - if (test ! -e $file) { - err '''%s'': Nonexistent.\n' $file + if (errdup $track <$file) { + echo $track >> $file } else { - if (isduplicate $track <$file) { - echo $track >> $file - } else { - warn '''%s'': Already contains this track.\n' $m3u - } + warn '''%s'': Already contains this track.\n' $m3u } }