mirror of
https://github.com/TheLocehiliosan/yadm
synced 2025-06-02 15:43:59 +00:00
Minor cleanups of alt handling
Also correct alt conditions precedence list in manual.
This commit is contained in:
parent
9ff5e09650
commit
bee1558a4e
11
yadm
11
yadm
@ -191,7 +191,11 @@ function score_file() {
|
||||
local -i delta=$((negate ? 1 : -1))
|
||||
case "$label" in
|
||||
default)
|
||||
delta=0
|
||||
if ((negate)); then
|
||||
INVALID_ALT+=("$source")
|
||||
else
|
||||
delta=0
|
||||
fi
|
||||
;;
|
||||
a | arch)
|
||||
[[ "$value" = "$local_arch" ]] && delta=1 || delta=-1
|
||||
@ -219,7 +223,7 @@ function score_file() {
|
||||
continue
|
||||
;;
|
||||
t | template | yadm)
|
||||
if [ -d "$source" ]; then
|
||||
if [ -d "$source" ] || ((negate)); then
|
||||
INVALID_ALT+=("$source")
|
||||
else
|
||||
template_processor=$(choose_template_processor "$value")
|
||||
@ -243,8 +247,7 @@ function score_file() {
|
||||
score=0
|
||||
return
|
||||
fi
|
||||
((negate)) || delta=$((delta + 1000))
|
||||
score=$((score + delta))
|
||||
score=$((score + delta + (negate ? 0 : 1000)))
|
||||
done
|
||||
|
||||
record_score "$score" "$target" "$source" "$template_processor"
|
||||
|
23
yadm.1
23
yadm.1
@ -512,6 +512,12 @@ Class must be manually set using
|
||||
See the CONFIGURATION section for more details about setting
|
||||
.BR local.class .
|
||||
.TP
|
||||
.BR distro_family ,\ f
|
||||
Valid if the value matches the distro family.
|
||||
Distro family is calculated by inspecting the ID_LIKE line from
|
||||
.B "/etc/os-release"
|
||||
(or ID if no ID_LIKE line is found).
|
||||
.TP
|
||||
.BR distro ,\ d
|
||||
Valid if the value matches the distro.
|
||||
Distro is calculated by running
|
||||
@ -519,12 +525,6 @@ Distro is calculated by running
|
||||
or by inspecting the ID from
|
||||
.BR "/etc/os-release" .
|
||||
.TP
|
||||
.BR distro_family ,\ f
|
||||
Valid if the value matches the distro family.
|
||||
Distro family is calculated by inspecting the ID_LIKE line from
|
||||
.B "/etc/os-release"
|
||||
(or ID if no ID_LIKE line is found).
|
||||
.TP
|
||||
.BR os ,\ o
|
||||
Valid if the value matches the OS.
|
||||
OS is calculated by running
|
||||
@ -573,13 +573,13 @@ files are managed by yadm's repository:
|
||||
|
||||
- $HOME/path/example.txt##default
|
||||
- $HOME/path/example.txt##class.Work
|
||||
- $HOME/path/example.txt##class.Work,~os.Darwin
|
||||
- $HOME/path/example.txt##os.Darwin
|
||||
- $HOME/path/example.txt##os.Darwin,hostname.host1
|
||||
- $HOME/path/example.txt##os.Darwin,hostname.host2
|
||||
- $HOME/path/example.txt##os.Linux
|
||||
- $HOME/path/example.txt##os.Linux,hostname.host1
|
||||
- $HOME/path/example.txt##os.Linux,hostname.host2
|
||||
- $HOME/path/example.txt##class.Work,~os.Darwin
|
||||
|
||||
If running on a Macbook named "host2",
|
||||
yadm will create a symbolic link which looks like this:
|
||||
@ -606,14 +606,13 @@ If running on a Macbook with class set to "Work", the link will be:
|
||||
|
||||
.IR $HOME/path/example.txt " -> " $HOME/path/example.txt##class.Work
|
||||
|
||||
Negative conditions are supported via the "~" prefix. If again running on a system
|
||||
with class set to "Work", but instead within Windows Subsystem for Linux, where the
|
||||
os is reported as WSL, the link will be:
|
||||
Since class has higher precedence than os, this version is chosen.
|
||||
|
||||
If running on a system with class set to "Work", but instead within Windows
|
||||
Subsystem for Linux, where the os is reported as WSL, the link will be:
|
||||
|
||||
.IR $HOME/path/example.txt " -> " $HOME/path/example.txt##class.Work,~os.Darwin
|
||||
|
||||
Negative conditions use the same weight which corresponds to the attached attribute.
|
||||
|
||||
If no "##default" version exists and no files have valid conditions, then no
|
||||
link will be created.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user