summaryrefslogtreecommitdiff
path: root/include/conflicts
blob: 1e119c00830033e7249f09c65d788568c0ad9be4 (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
#!/usr/bin/env zsh
## vim:ft=zsh
typeset file dir i
typeset PDIR=$HOME/packages
typeset -a sfpath spath conflict

is_in_path () {
	typeset -i ret=1
	typeset dir
	typeset file=$1
	shift
	for dir in $@; {
		if [[ -e $dir/$file ]] {
			ret=0
			echo $dir/$file
		}
	}
	return $ret
}

# a simple sfpath=${fpath:#${HOME}*} won't work
for i in ${fpath:#${HOME}*}; {
	sfpath+=$i
}
for i in ${path:#${HOME}*}; {
	spath+=$i
}

for file in $PDIR/{*/provides/zsh/completions/*(N),zsh/etc/completions/*(N)}; {
	conflict=($(is_in_path ${file:t} $sfpath))
	if (( ? == 0 )) {
		echo "conflict: $file <-> ${(j:, :)conflict}"
	}
}

for file in $PDIR/*/bin/*(N); {
	conflict=($(is_in_path ${file:t} $spath))
	if (( ? == 0 )) {
		echo "conflict: $file <-> ${(j:, :)conflict}"
	}
}