#!/bin/bash ###################################################################### ### bash <(curl -fsSL https://raw.lhy.life/clang.sh) --version=18 ###################################################################### if dpkg -l 'g++*' 2>/dev/null | grep "^ii"; then apt purge 'clang*' 'lldb*' 'lld*' 'clangd*' 'g++*' -y apt autopurge -y fi ## GetArgValue ## ./script --key=value g_args=("$@") function GetArgValue() { local key="$1" local defvalue="$2" for arg in "${g_args[@]}" do if [[ "$arg" == "--$key="* ]] then echo "${arg#*=}" return fi done echo "$defvalue" } VERSION=$(GetArgValue "version" "") if [ -n "$VERSION" ]; then VERSION="-$VERSION" fi apt update && apt install lsb-release wget gnupg g++-multilib git make -y apt install clang$VERSION lldb$VERSION lld$VERSION clangd$VERSION -y sed -i "/^export PATH=\/usr\/lib\/llvm/d" /etc/profile sed -i "/^export CC=/d" /etc/profile sed -i "/^export CXX=/d" /etc/profile if [ -n "$VERSION" ]; then echo "export PATH=/usr/lib/llvm$VERSION/bin:\$PATH" >> /etc/profile fi echo 'export CC=clang' >> /etc/profile echo 'export CXX=clang++' >> /etc/profile