#!/usr/bin/env zsh # # Copyright © 2010-2012 Nick Bowler # # License WTFPL2: Do What The Fuck You Want To Public License, version 2. # This is free software: you are free to do what the fuck you want to. # There is NO WARRANTY, to the extent permitted by law. # # A convenient script to download an OpenGL extension specification from the # Khronos registry into the current working directory. IFS=_ extension=(${=1}) case $extension[1] in GL|GLX|WGL) ;; *) extension=(GL $extension) ;; esac api=$extension[1] vendor=$extension[2] name=${(j:_:)extension[3,-1]} fullname=${(j:_:)extension} if [[ -z $api || -z $vendor || -z $name ]]; then printf 'usage: %s extension\n' $0 1>&2 exit 1 fi urls=( http://www.opengl.org/registry/specs/$vendor/$name.txt http://www.opengl.org/registry/specs/$vendor/${api:l}_$name.txt ) for url in $urls; do if wget -O $fullname $url; then gzip -f $fullname || exit 1 exit 0 fi rm -f $fullname done exit 1