-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·62 lines (55 loc) · 1.58 KB
/
install.sh
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
#! /bin/bash
# Process substitution
show_syntax() {
printf "usage: ./%s < -y ~/bin/ | --skipped >\n
-s | --skipped
List files not installed
-y Write symlinks (ln -snv) into the specified directory.\n
-yS Install (only) the scary \"read it before running\" shortcuts.\n
This isn't so much an install, as placing the files the author likes
on \$PATH the way he does it.\n
It is ideminpotent: it will not overwrite existing files or links.\n
After the first install, the install destination is remembered and
can be omitted to install additional files.\n" \
"$( basename $0 )"
}
do_inst() {
local src dest instand leaf
dest="$1"
instand="$2"
if [ -z "$dest" ]; then
dest="$( git config plumbed-in-from.PATH )"
if [ -z "$dest" ]; then
show_syntax
exit 1
fi
dest="$( dirname "$dest" )"
echo "Using previous install directory $dest"
fi
src="$PWD"
if ! [ -d "$dest" ] || ! [ -w "$dest" ]; then
echo "$0: $dest is not a writable directory" >&2
return 2
fi
ln -snv "$src/bin" "$dest/,git-yacontrib"
git config plumbed-in-from.PATH "$dest/,git-yacontrib" # my suggested convention
for leaf in $( cat "$src/$instand" ); do
ln -snv ",git-yacontrib/$leaf" "$dest"
done
}
show_skipped() {
local src
src="$PWD"
diff -u \
<( LC_ALL=C sort "$src"/install*.txt ) \
<( find bin -type f -printf "%f\n" | LC_ALL=C sort )
}
unset CDPATH
cd "$( dirname "$0" )"
case "$1" in
-y) do_inst "$2" install.txt ;;
-yS) do_inst "$2" install-scary.txt ;;
# -h | --help)
-s|--skipped) show_skipped ;;
*) show_syntax ;;
esac