Files
would-reformat/install.sh
2020-08-12 13:49:47 -05:00

53 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
set -uo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
here=$(pwd)
ret=0
# If this use of readlink breaks, see
# https://unix.stackexchange.com/questions/47710/find-only-destination-of-symlink
# for discussion of alternatives.
for i in _reformat-common.sh do-reformat.sh would-reformat.sh; do
if [[ -f "$here"/bin/"$i" ]] ; then
dest=$(readlink bin/$i)
if [[ x"$dest" == x"$DIR/$i" ]] ; then
echo $i is in place, good
else
echo $i exists but it is not a symlink or does not point to the right place
echo If it is a symlink, it points to: $dest
echo "(If it doesn't point anywhere, then it probably is not a symlink)"
ret=1
fi
else
# it doesn't exist; create it
echo setting $i up
mkdir -p $here/bin
ln -s $DIR/$i $here/bin/$i
fi
done
if [[ -f $here/.dir-locals.el ]] ; then
dest=$(readlink .dir-locals.el)
if [[ x"$dest" == x"$DIR/_dir-locals.el" ]] ; then
echo .dir-locals.el is in place, good
else
echo .dir-locals.el exists but it is not a symlink or does not point to
echo the right place
echo
echo It is possible that you are using .dir-locals.el for other purposes,
echo in which case this is not really an error.
ret=1
fi
else
echo setting .dir-locals.el up
ln -s $DIR/_dir-locals.el $here/.dir-locals.el
fi
exit $ret