#!/bin/sh src="$1" shift filename="${src##*/}" filename="${filename%.*}" runcache="$HOME/.cache/C" CC=cc # need to compile? (use not -ot to circumvent inexisting file the first time) if [ ! "$src" -ot "$runcache/$filename" ]; then mkdir -p "$runcache" # get rid of shebang line in C program and compile it tail -n +2 "$src" > "$runcache/$filename.c" if [ -r /usr/bin/clang ]; then CC=clang fi "$CC" -Wall -std=c99 $CC_OPTS -o "$runcache/$filename" "$runcache/$filename.c" fi exec "$runcache/$filename" "$@"