Skip to content

Instantly share code, notes, and snippets.

@maoe
Created November 17, 2018 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maoe/f345fee3c5b8b26a207cc43d9a381755 to your computer and use it in GitHub Desktop.
Save maoe/f345fee3c5b8b26a207cc43d9a381755 to your computer and use it in GitHub Desktop.
Update symlinks for GHC
#!/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