Skip to content
Newer
Older
100755 36 lines (33 sloc) 952 Bytes
add8d79 @jferris Install script
jferris authored Jan 13, 2011
1 #!/bin/sh
2
3 cutstring="DO NOT EDIT BELOW THIS LINE"
4
5 for name in *; do
6 target="$HOME/.$name"
b89501e @wolfeidau Now posix compatible and I have removed the use of tail -r
wolfeidau authored Oct 15, 2011
7 if [ -e "$target" ]; then
8 if [ ! -L "$target" ]; then
add8d79 @jferris Install script
jferris authored Jan 13, 2011
9 cutline=`grep -n -m1 "$cutstring" "$target" | sed "s/:.*//"`
b89501e @wolfeidau Now posix compatible and I have removed the use of tail -r
wolfeidau authored Oct 15, 2011
10 if [ -n "$cutline" ]; then
11 cutline=$((cutline-1))
add8d79 @jferris Install script
jferris authored Jan 13, 2011
12 echo "Updating $target"
13 head -n $cutline "$target" > update_tmp
b89501e @wolfeidau Now posix compatible and I have removed the use of tail -r
wolfeidau authored Oct 15, 2011
14 startline=`sed '1!G;h;$!d' "$name" | grep -n -m1 "$cutstring" | sed "s/:.*//"`
15 if [ -n "$startline" ]; then
add8d79 @jferris Install script
jferris authored Jan 13, 2011
16 tail -n $startline "$name" >> update_tmp
17 else
18 cat "$name" >> update_tmp
19 fi
20 mv update_tmp "$target"
21 else
22 echo "WARNING: $target exists but is not a symlink."
23 fi
24 fi
25 else
b89501e @wolfeidau Now posix compatible and I have removed the use of tail -r
wolfeidau authored Oct 15, 2011
26 if [ "$name" != 'install.sh' ]; then
add8d79 @jferris Install script
jferris authored Jan 13, 2011
27 echo "Creating $target"
b89501e @wolfeidau Now posix compatible and I have removed the use of tail -r
wolfeidau authored Oct 15, 2011
28 if [ -n "$(grep "$cutstring" "$name")" ]; then
add8d79 @jferris Install script
jferris authored Jan 13, 2011
29 cp "$PWD/$name" "$target"
30 else
31 ln -s "$PWD/$name" "$target"
32 fi
33 fi
34 fi
35 done
Something went wrong with that request. Please try again.