bf=$1 ir_pat=" s/>/0/g; s/</1/g; s/+/2/g; s/-/3/g; s/./4/g; s/,/5/g; s/[/6/g; s/]/7/g" c_pat=" s/0/++ptr;/g; s/1/--ptr;/g; s/2/++*ptr;/g; s/3/--*ptr;/g; s/4/putchar(*ptr);/g; s/5/*ptr=getchar();/g; s/6/while(*ptr){/g; s/7/}/g" ir=`cat $bf | sed -e "$ir_pat"` c=`echo $ir | sed -e "$c_pat"` src="#include <stdio.h> \\n int main(void){ \\n unsigned char tape[100000] = {0,}; \\n unsigned char* ptr = tape; \\n ${c} \\n }" echo -e $src | gcc -O2 -xc -
$ cat hw.bf
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
$ sh bfc.sh hw.bf
$ ./a.out
Hello World!
-O2 라서 존나 빠름
날먹 또 날먹 하십시오
감사합니다
깃헙이야기
push -f origin master
정규표현식 만세!
????
개추박았읍니다
헉
이걸로 버퍼 오버플로우 하는 상상함 ㅋㅋ - dc App