Skip to content

Instantly share code, notes, and snippets.

@valgur
Forked from gburca/update-alternatives-clang.sh
Last active July 6, 2019 12:25
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 valgur/99533fa92f2c7527a22a3b2ae34fb490 to your computer and use it in GitHub Desktop.
Save valgur/99533fa92f2c7527a22a3b2ae34fb490 to your computer and use it in GitHub Desktop.
Automatically find and 'update-alternatives --install' installed clang versions
#!/bin/bash
BIN=/usr/bin
MAN=/usr/share/man/man1
function register_clang_version {
BINV=$1
PRIORITY=`echo $BINV | awk '{print int($1 * 10)}'`
update-alternatives --install $BIN/clang clang $BIN/clang-$BINV $PRIORITY \
--slave $BIN/clang++ clang++ $BIN/clang++-$BINV
}
versions=`compgen -c clang++- | cut -d- -f 2`
echo Found clang versions: $versions
for version in $versions; do
echo Installing $version
register_clang_version $version
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment