Files
would-reformat/install.sh
2023-09-30 17:27:53 -06:00

58 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
set -uo pipefail
IFS=$'\n\t'
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
here=$(pwd)
pushd "$DIR" || exit 255
rm -f .root
pwd >.root
popd || exit 255
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.bash do-reformat.sh would-reformat.sh _wrflog.sh .root; do
if [[ -f "$here"/bin/"$i" ]]; then
dest=$(readlink bin/"$i")
if [[ "$dest" == "$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 [[ "$dest" == "$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