Created
November 23, 2020 17:56
-
-
Save HarryR/0ab66145b7a8edbf8a57323b2073683c to your computer and use it in GitHub Desktop.
Download solidity compiler
This file contains 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
#!/usr/bin/env bash | |
if [[ -z $1 ]]; then | |
>&2 echo "Usage: `basename $0` [N.M|latest]" | |
>&2 echo "" | |
>&2 echo "Example to download v0.7.2:" | |
>&2 echo "" | |
>&2 echo ' $' "`basename $0` 7.2" | |
>&2 echo "" | |
>&2 echo "Example to download latest version:" | |
>&2 echo "" | |
>&2 echo ' $' "`basename $0` latest" | |
>&2 echo "" | |
>&2 echo "Versions Downloaded:" | |
>&2 echo "" | |
for name in solc-static-linux-v* | |
do | |
echo -n ' v' | |
echo $name | cut -f 2 -d 'v' | |
done | |
exit 1 | |
fi | |
if [[ $1 == "latest" ]]; then | |
latest=`curl -s 'https://github.com/ethereum/solidity/releases.atom' | grep ethereum/solidity/releases/tag/v0 | cut -f 2 -d 'v' | cut -f 1 -d '"' | cut -f 2- -d '.' | head -n 1` | |
solc_ver="v0.$latest" | |
else | |
solc_ver="v0.$1" | |
fi | |
solc_url="https://github.com/ethereum/solidity/releases/download/$solc_ver/solc-static-linux" | |
solc_bin="solc-static-linux-$solc_ver" | |
if [[ -f $solc_bin ]]; then | |
>&2 echo "Note: $solc_bin file already exists!" | |
exit 0 | |
fi | |
echo "Downloading..." | |
echo " From: $solc_url" | |
echo " To: $solc_bin" | |
wget -q --show-progress --progress=bar -O "$solc_bin" "$solc_url" | |
if [[ $? -ne 0 ]]; then | |
>&2 echo "Error: failed to download! code $?" | |
rm -f "$solc_bin" | |
exit 2 | |
fi | |
chmod 755 "$solc_bin" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment