-
Notifications
You must be signed in to change notification settings - Fork 2
/
add-to-site-start
executable file
·56 lines (50 loc) · 1.02 KB
/
add-to-site-start
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
#!/bin/sh
#
# add-to-site-start: add files and directories to ~/.emacs.d/site-start.d/
# era 2009-01-21
#
# Compatibility notes:
# ${var##subst} may not be supported in pre-POSIX /bin/sh implementations
DEST=$HOME/.emacs.d/site-start.d
RC=1
me=${0##*/}
while :; do
case $# in 0) RC=127; set -- --help triggered below ;; esac
case $1 in
-h|-\?|--help)
cat <<____________HERE >&2
Syntax: $me [--dest path-to-site-start-dir ] file|dir ...
For each argument, add a symlink to it to the site-start directory
____________HERE
exit $RC
;;
-d|--dir|--directory|--dest|--destination)
shift
DEST=$1
shift
;;
-*)
echo "$me: invalid argument $1" >&2
RC=255
set -- --help triggered on next iteration
;;
*)
break ;;
esac
done
if ! [ -d "$DEST" ]; then
echo "$me: creating $DEST"
mkdir -p "$DEST" || exit $?
fi
p=$(pwd)
RC=0
for file; do
f=${file%/.}
case $f in
/*) ;;
.) f=$p ;;
*) f="$p"/"$f" ;;
esac
ln -s "$f" "$DEST" || RC=$?
done
exit $RC