mirror of
https://github.com/TheLocehiliosan/yadm
synced 2025-06-04 08:33:57 +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))
|
local -i delta=$((negate ? 1 : -1))
|
||||||
case "$label" in
|
case "$label" in
|
||||||
default)
|
default)
|
||||||
delta=0
|
if ((negate)); then
|
||||||
|
INVALID_ALT+=("$source")
|
||||||
|
else
|
||||||
|
delta=0
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
a | arch)
|
a | arch)
|
||||||
[[ "$value" = "$local_arch" ]] && delta=1 || delta=-1
|
[[ "$value" = "$local_arch" ]] && delta=1 || delta=-1
|
||||||
@ -219,7 +223,7 @@ function score_file() {
|
|||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
t | template | yadm)
|
t | template | yadm)
|
||||||
if [ -d "$source" ]; then
|
if [ -d "$source" ] || ((negate)); then
|
||||||
INVALID_ALT+=("$source")
|
INVALID_ALT+=("$source")
|
||||||
else
|
else
|
||||||
template_processor=$(choose_template_processor "$value")
|
template_processor=$(choose_template_processor "$value")
|
||||||
@ -243,8 +247,7 @@ function score_file() {
|
|||||||
score=0
|
score=0
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
((negate)) || delta=$((delta + 1000))
|
score=$((score + delta + (negate ? 0 : 1000)))
|
||||||
score=$((score + delta))
|
|
||||||
done
|
done
|
||||||
|
|
||||||
record_score "$score" "$target" "$source" "$template_processor"
|
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
|
See the CONFIGURATION section for more details about setting
|
||||||
.BR local.class .
|
.BR local.class .
|
||||||
.TP
|
.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
|
.BR distro ,\ d
|
||||||
Valid if the value matches the distro.
|
Valid if the value matches the distro.
|
||||||
Distro is calculated by running
|
Distro is calculated by running
|
||||||
@ -519,12 +525,6 @@ Distro is calculated by running
|
|||||||
or by inspecting the ID from
|
or by inspecting the ID from
|
||||||
.BR "/etc/os-release" .
|
.BR "/etc/os-release" .
|
||||||
.TP
|
.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
|
.BR os ,\ o
|
||||||
Valid if the value matches the OS.
|
Valid if the value matches the OS.
|
||||||
OS is calculated by running
|
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##default
|
||||||
- $HOME/path/example.txt##class.Work
|
- $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
|
||||||
- $HOME/path/example.txt##os.Darwin,hostname.host1
|
- $HOME/path/example.txt##os.Darwin,hostname.host1
|
||||||
- $HOME/path/example.txt##os.Darwin,hostname.host2
|
- $HOME/path/example.txt##os.Darwin,hostname.host2
|
||||||
- $HOME/path/example.txt##os.Linux
|
- $HOME/path/example.txt##os.Linux
|
||||||
- $HOME/path/example.txt##os.Linux,hostname.host1
|
- $HOME/path/example.txt##os.Linux,hostname.host1
|
||||||
- $HOME/path/example.txt##os.Linux,hostname.host2
|
- $HOME/path/example.txt##os.Linux,hostname.host2
|
||||||
- $HOME/path/example.txt##class.Work,~os.Darwin
|
|
||||||
|
|
||||||
If running on a Macbook named "host2",
|
If running on a Macbook named "host2",
|
||||||
yadm will create a symbolic link which looks like this:
|
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
|
.IR $HOME/path/example.txt " -> " $HOME/path/example.txt##class.Work
|
||||||
|
|
||||||
Negative conditions are supported via the "~" prefix. If again running on a system
|
Since class has higher precedence than os, this version is chosen.
|
||||||
with class set to "Work", but instead within Windows Subsystem for Linux, where the
|
|
||||||
os is reported as WSL, the link will be:
|
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
|
.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
|
If no "##default" version exists and no files have valid conditions, then no
|
||||||
link will be created.
|
link will be created.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user