Skip to content

Instantly share code, notes, and snippets.

@spikegrobstein
Last active June 7, 2016 21:34
Show Gist options
  • Save spikegrobstein/69988f51d36ff817ee610c1dae77bd39 to your computer and use it in GitHub Desktop.
Save spikegrobstein/69988f51d36ff817ee610c1dae77bd39 to your computer and use it in GitHub Desktop.
Yeah, run it like this: ./curlcc.sh "https://spike.cx/d/me.c" is doing something very risky
#! /bin/bash
# vi:ft=sh
url=$1; shift
headers_file=/tmp/curlcc-tmp.headers
ofile=/tmp/curlcc-tmp.ofile.c
execfile=/tmp/curlcc-tmp.exec
curl -s -o "$ofile" -D "$headers_file" "$url"
content_type=$( cat "$headers_file" | grep -i 'Content-type' | awk -F ': ' '{ print $2 }' | tr -d '\r' )
if [[ "$content_type" != "text/x-csrc" ]]; then
echo "Incorrect content type. can't do: '$content_type'"
exit 1
fi
gcc -o "$execfile" "$ofile"
"$execfile" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment