Created
November 17, 2018 14:07
-
-
Save maoe/f345fee3c5b8b26a207cc43d9a381755 to your computer and use it in GitHub Desktop.
Update symlinks for GHC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
EXECUTABLES="ghc ghc-pkg ghci haddock runghc" | |
VERSION=$1 | |
if [ -z "$1" ]; then | |
echo "ERROR: GHC version number needs to be specified. Exiting." 1>&2 | |
exit 1 | |
fi | |
pushd /opt/ghc/bin > /dev/null | |
for exe in ${EXECUTABLES}; do | |
ls -l ${exe} | grep ${VERSION} >/dev/null | |
[[ $? -eq 0 ]] && exit 0 | |
if [ ! -x ${exe}-${VERSION} -a ! -x "haddock-ghc-${VERSION}" ]; then | |
echo "ERROR: ${exe}-${VERSION} doesn't exist. Skipping." 1>&2 | |
continue | |
fi | |
echo -n "Updating ${exe}..." | |
sudo rm ${exe} | |
if [ ${exe} = "haddock" ]; then | |
sudo ln -s "haddock-ghc-${VERSION}" ${exe} | |
else | |
sudo ln -s ${exe}-${VERSION} ${exe} | |
fi | |
echo " done" | |
done | |
popd > /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment