commit ec685153e7686a674212ee347ff79321a01eafb6
parent 744f6b9f080009171de40977594f2dc9d7ac8775
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Mon, 23 Nov 2020 15:17:11 -0800
Rework sysconf to work with relative config files
Use filenames similar to make(1) with an added .sysconf.
Diffstat:
3 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
@@ -8,7 +8,6 @@ MODULES = git\
scripts\
shell\
sxiv\
- sysconf\
tmux\
vim\
vimb\
diff --git a/modules/scripts/.local/bin/sysconf b/modules/scripts/.local/bin/sysconf
@@ -8,8 +8,8 @@
#! is evaluated with rc(1)'s eval then executed. The format of each
#! item should be `$src[<tab><space>]+$dst'.
#!
-#! sysconf first checks SYSCONF for the list, then
-#! XDG_CONFIG_HOME/sysconf, and finally HOME/.config/sysconf.
+#! Configuration files are takin in the following order: first
+#! `sysconf', then `Sysconf', and finaly `.sysconf'.
__progname = `{ basename $0 }
@@ -25,11 +25,18 @@ fn match { egrep $* }
fn intern { }
fn execute {
if (test $#* -ne 2) {
- warn 'execute: Invalid argument count (%d).\n' $#* >[2=1]
+ warn 'execute: Invalid argument count (%d).\n' $#*
return 1
}
intern $*
}
+fn list_configs {
+ stest -e sysconf Sysconf .sysconf || {
+ if (test $status -eq 1)
+ err 'No config file.\n';
+ exit 1
+ }
+}
if (test $#* -lt 1)
* = ('ls');
@@ -58,18 +65,13 @@ switch ($1) {
err '''%s'': Invalid command.\n' $1
}
-if (test -z $SYSCONF) {
- if (test -z $XDG_CONFIG_HOME)
- XDG_CONFIG_HOME = $HOME^/.config;
- SYSCONF = $XDG_CONFIG_HOME^/sysconf
-}
-
+config = `{ list_configs | head -1 }
ifs = '
'
if (test $#* -eq 1) {
- commands = `{ filter $SYSCONF }
+ commands = `{ filter $config }
} else if (test $#* -eq 2) {
- commands = `{ filter $SYSCONF | match $2 }
+ commands = `{ filter $config | match $2 }
} else
err '''%d'': Too many arguments given.\n' $#*;
diff --git a/modules/sysconf/.config/sysconf b/sysconf