blob: 00fbd41c51daa2b8f515e1283ad9625c0c1d5fef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/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" "$@"
|