Mercurial > repo
annotate bin/gccrun @ 4211:d616398f84e7
<fizzie> sed -i -e \'s/| head //\' bin/quoth # gonna bork it up somehow...
author | HackBot |
---|---|
date | Fri, 20 Dec 2013 13:57:08 +0000 |
parents | f2cd1846ed06 |
children |
rev | line source |
---|---|
2660 | 1 #!/bin/sh |
2 | |
3 if [ "$#" = 0 ]; then | |
4 echo "usage: $0 [-w wrapper] <C code...>" >&2 | |
5 exit 1 | |
6 fi | |
7 | |
8 if [ "$1" = -w ]; then | |
9 wrapper="$2" | |
10 shift 2 | |
11 fi | |
12 | |
13 f=$(mktemp -d -t gccrun.XXXXXXXX) || exit 1 | |
14 cat > "$f/command.c" << EOF | |
15 #define _GNU_SOURCE | |
16 #include <sys/types.h> | |
17 #include <sys/stat.h> | |
18 #include <sys/mman.h> | |
19 #include <sys/ptrace.h> | |
20 #include <sys/syscall.h> | |
21 #include <arpa/inet.h> | |
22 #include <errno.h> | |
23 #include <fcntl.h> | |
24 #include <signal.h> | |
25 #include <stdio.h> | |
26 #include <stdlib.h> | |
27 #include <string.h> | |
28 #include <unistd.h> | |
3405 | 29 #include <math.h> |
2660 | 30 |
31 int | |
32 main(int argc, char *argv[], char *envp[]) | |
33 { | |
34 $1; | |
35 return 0; | |
36 } | |
37 EOF | |
38 shift | |
3400
92909601a36d
<Jafet> sed -e \'s/\\$\\@/\\$\\@ -lm/\' -i bin/gccrun
HackBot
parents:
2660
diff
changeset
|
39 if ! gcc -o "$f/command" "$f/command.c" $@ -lm; then |
2660 | 40 exit 1 |
41 fi | |
42 if [ -n "$wrapper" ]; then | |
43 $wrapper "$f/command" | |
44 else | |
45 "$f/command" | |
46 fi | |
47 r=$? | |
48 rm -r "$f" | |
3405 | 49 exit $r |