Now posix compatible and I have removed the use of tail -r

This commit is contained in:
Mark Wolfe 2011-10-15 18:33:17 +11:00
parent dc4c65e7ca
commit b89501eede

View file

@ -4,15 +4,15 @@ cutstring="DO NOT EDIT BELOW THIS LINE"
for name in *; do
target="$HOME/.$name"
if [ -e $target ]; then
if [ ! -L $target ]; then
if [ -e "$target" ]; then
if [ ! -L "$target" ]; then
cutline=`grep -n -m1 "$cutstring" "$target" | sed "s/:.*//"`
if [[ -n $cutline ]]; then
let "cutline = $cutline - 1"
if [ -n "$cutline" ]; then
cutline=$((cutline-1))
echo "Updating $target"
head -n $cutline "$target" > update_tmp
startline=`tail -r "$name" | grep -n -m1 "$cutstring" | sed "s/:.*//"`
if [[ -n $startline ]]; then
startline=`sed '1!G;h;$!d' "$name" | grep -n -m1 "$cutstring" | sed "s/:.*//"`
if [ -n "$startline" ]; then
tail -n $startline "$name" >> update_tmp
else
cat "$name" >> update_tmp
@ -23,9 +23,9 @@ for name in *; do
fi
fi
else
if [[ $name != 'install.sh' ]]; then
if [ "$name" != 'install.sh' ]; then
echo "Creating $target"
if [[ -n `grep "$cutstring" "$name"` ]]; then
if [ -n "$(grep "$cutstring" "$name")" ]; then
cp "$PWD/$name" "$target"
else
ln -s "$PWD/$name" "$target"