Skip to content

Instantly share code, notes, and snippets.

@unascribed
Created November 13, 2014 10:10
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 unascribed/e4bfddf7226d30bf40c8 to your computer and use it in GitHub Desktop.
Save unascribed/e4bfddf7226d30bf40c8 to your computer and use it in GitHub Desktop.
if [ "$DESIRED_RELEASE" == "recommended" ]; then
# this is unholy, but Forge doesn't appear to supply an API, and
# their Maven repo appears to not be well formed
DESIRED_RELEASE=`curl -s http://files.minecraftforge.net/ |
grep -m 1 -A 2 '<td>Recommended' |
grep -v 'Recommended' |
cut -d '>' -f 2 |
cut -d '<' -f 1 |
tac |
head -c -1 |
tr '\n' '-'`
# so, here's what we just did
# curl gets the main forge files page, that should be obvious
# the first grep looks for the 'Recommended' build line
# the -m 1 makes it give up when it finds it, which cancels curl
# this prevents us from downloading the whole page
# the two cuts get rid of the td tags and their closers
# tac reverses it so that it's like a forge version
# head removes the trailing newline
# tr turns the newlines into dashes
# we now have a valid forge version number
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment