blob: e1e1709c3e49e3bb37a08166a992420766b3cd0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#!/usr/bin/env sh
# Convenient frontend for quickly evaluating C code
LIBR="stdlib stdio math ieee754 limits stdint stdstring"
FLAG="-Wall -lm"
gen_rand() {
od -A n -t d -N 1 /dev/urandom | tr -d ' '
}
NAME=/tmp/$(gen_rand)-$(gen_rand)
SRC=$NAME.c
BIN=$NAME-B
for k in $LIBR; do
echo "#include<$k.h>" >> $SRC
done
echo "int main(int argc, char ** argv) {" >> $SRC
rlwrap -o cat >> $SRC
echo "return 0;}" >> $SRC
printf "\n\n\t!!! Compiling ..."
cc $FLAG $SRC -o $BIN
if [ "$?" = "0" ]; then
printf "\n\n\t!!! Executing ...\n\n"
exec $BIN
rm $BIN
fi;
rm $SRC
|