summaryrefslogtreecommitdiff
path: root/test/checklinks
blob: 9c2894de4644c155e1ce4a643b655bb02a77dbf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
## vim:ft=zsh

cat > links <<- quux
	foo ignored
	# ignored
	hard foo bar
	soft link file
	soft blub \$quux
quux

alias checklinks='checklinks --parameter quux=flurbl --msglevel 99'

echo barbl > bar
echo flurbl > file
echo morp > flurbl

echo "# checklinks"
checklinks
[[ $(cat foo) == $(cat bar) ]]
[[ $(cat link) == $(cat file) ]]
[[ $(cat blub) == $(cat flurbl) ]]

echo "# checklinks --remove"
checklinks --remove
[[ ! -e foo ]]
[[ -e bar ]]
[[ ! -e link ]]
[[ -e file ]]
[[ ! -e blub ]]
[[ -e flurbl ]]

echo "# checklinks: link source exists already"
echo exists > link
! checklinks
[[ $(cat link) == exists ]]

rm bar file flurbl foo link blub
mkdir ~/cl
cd ~/cl

echo "# checklinks: auto (normal files)"

echo auto > links
touch n1 n2
checklinks

[[ -e ~/.n1 ]]
[[ -e ~/.n2 ]]

checklinks --remove

[[ ! -e ~/.n1 ]]
[[ ! -e ~/.n2 ]]

echo "# checkliks: auto (normal files + dotfiles)"

touch .d1 .d2
checklinks

[[ -e ~/.d1 ]]
[[ -e ~/.d2 ]]
[[ ! -e ~/.n1 ]]
[[ ! -e ~/.n2 ]]
[[ ! -e ~/n1 ]]
[[ ! -e ~/n2 ]]

checklinks --remove

[[ ! -e ~/.d1 ]]
[[ ! -e ~/.d2 ]]

echo "# checklinks: auto (dotfiles)"

rm n1 n2
checklinks

[[ -e ~/.d1 ]]
[[ -e ~/.d2 ]]

checklinks --remove

[[ ! -e ~/.d1 ]]
[[ ! -e ~/.d2 ]]

rm links

echo "# checklinks: --ct-auto (no etc)"

touch foo bar
checklinks --ct-auto

[[ ! -e ~/.foo ]]
[[ ! -e ~/.bar ]]

echo "# checklinks: --ct-auto (etc with links file)"

touch links
checklinks --ct-auto

[[ ! -e ~/.foo ]]
[[ ! -e ~/.bar ]]

rm links

echo "# checklinks: --ct-auto (etc with files)"

mkdir etc
touch etc/{the,dude}
checklinks --ct-auto

[[ -e ~/.the ]]
[[ -e ~/.dude ]]

checklinks --ct-auto --remove

[[ ! -e ~/.the ]]
[[ ! -e ~/.dude ]]