Last active
August 29, 2015 14:07
-
-
Save nvie/35cb300f4eda215a815d to your computer and use it in GitHub Desktop.
Different highlights of this piece of code that is valid C, C++, awk, perl, Python, sh, bash and tcl: https://github.com/stedolan/hax/blob/master/twisty_code/megascript.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef _not_defined | |
#\ | |
"exit`[ -z $BASH ] && t=sh; [ -z $BASH ] || t=$(basename $BASH); echo Hello, World from $t > /dev/tty;`"; | |
"[puts {Hello, World from Tcl}; {exit}]"; | |
from operator import concat; | |
exec concat(concat(concat(chr(109),chr(61)),chr(39)),chr(39)); | |
m,""" ";/,;s/;//; | |
#else | |
#include <stdio.h> | |
#define BEGIN int main(int nargs,char** args) | |
#define print(a) printf("%s","Hello, World from C\n") | |
#ifdef __cplusplus | |
#undef print | |
#define print(a) printf("%s","Hello, World from C++\n") | |
#endif | |
#define exit return 0 | |
BEGIN { | |
#ifdef _still_not_defined | |
$crap = " from Perl"; | |
$0 = "Hello, World$crap\n"; | |
$NF = "World from awk"; | |
#endif | |
print($0); | |
exit; | |
} | |
#endif | |
#ifdef _i_wont_define_it_so_stop_asking | |
# """; print "Hello, World from Python" # " | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef _not_defined | |
#\ | |
"exit`[ -z $BASH ] && t=sh; [ -z $BASH ] || t=$(basename $BASH); echo Hello, World from $t > /dev/tty;`"; | |
"[puts {Hello, World from Tcl}; {exit}]"; | |
from operator import concat; | |
exec concat(concat(concat(chr(109),chr(61)),chr(39)),chr(39)); | |
m,""" ";/,;s/;//; | |
#else | |
#include <stdio.h> | |
#define BEGIN int main(int nargs,char** args) | |
#define print(a) printf("%s","Hello, World from C\n") | |
#ifdef __cplusplus | |
#undef print | |
#define print(a) printf("%s","Hello, World from C++\n") | |
#endif | |
#define exit return 0 | |
BEGIN { | |
#ifdef _still_not_defined | |
$crap = " from Perl"; | |
$0 = "Hello, World$crap\n"; | |
$NF = "World from awk"; | |
#endif | |
print($0); | |
exit; | |
} | |
#endif | |
#ifdef _i_wont_define_it_so_stop_asking | |
# """; print "Hello, World from Python" # " | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef _not_defined | |
#\ | |
"exit`[ -z $BASH ] && t=sh; [ -z $BASH ] || t=$(basename $BASH); echo Hello, World from $t > /dev/tty;`"; | |
"[puts {Hello, World from Tcl}; {exit}]"; | |
from operator import concat; | |
exec concat(concat(concat(chr(109),chr(61)),chr(39)),chr(39)); | |
m,""" ";/,;s/;//; | |
#else | |
#include <stdio.h> | |
#define BEGIN int main(int nargs,char** args) | |
#define print(a) printf("%s","Hello, World from C\n") | |
#ifdef __cplusplus | |
#undef print | |
#define print(a) printf("%s","Hello, World from C++\n") | |
#endif | |
#define exit return 0 | |
BEGIN { | |
#ifdef _still_not_defined | |
$crap = " from Perl"; | |
$0 = "Hello, World$crap\n"; | |
$NF = "World from awk"; | |
#endif | |
print($0); | |
exit; | |
} | |
#endif | |
#ifdef _i_wont_define_it_so_stop_asking | |
# """; print "Hello, World from Python" # " | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef _not_defined | |
#\ | |
"exit`[ -z $BASH ] && t=sh; [ -z $BASH ] || t=$(basename $BASH); echo Hello, World from $t > /dev/tty;`"; | |
"[puts {Hello, World from Tcl}; {exit}]"; | |
from operator import concat; | |
exec concat(concat(concat(chr(109),chr(61)),chr(39)),chr(39)); | |
m,""" ";/,;s/;//; | |
#else | |
#include <stdio.h> | |
#define BEGIN int main(int nargs,char** args) | |
#define print(a) printf("%s","Hello, World from C\n") | |
#ifdef __cplusplus | |
#undef print | |
#define print(a) printf("%s","Hello, World from C++\n") | |
#endif | |
#define exit return 0 | |
BEGIN { | |
#ifdef _still_not_defined | |
$crap = " from Perl"; | |
$0 = "Hello, World$crap\n"; | |
$NF = "World from awk"; | |
#endif | |
print($0); | |
exit; | |
} | |
#endif | |
#ifdef _i_wont_define_it_so_stop_asking | |
# """; print "Hello, World from Python" # " | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef _not_defined | |
#\ | |
"exit`[ -z $BASH ] && t=sh; [ -z $BASH ] || t=$(basename $BASH); echo Hello, World from $t > /dev/tty;`"; | |
"[puts {Hello, World from Tcl}; {exit}]"; | |
from operator import concat; | |
exec concat(concat(concat(chr(109),chr(61)),chr(39)),chr(39)); | |
m,""" ";/,;s/;//; | |
#else | |
#include <stdio.h> | |
#define BEGIN int main(int nargs,char** args) | |
#define print(a) printf("%s","Hello, World from C\n") | |
#ifdef __cplusplus | |
#undef print | |
#define print(a) printf("%s","Hello, World from C++\n") | |
#endif | |
#define exit return 0 | |
BEGIN { | |
#ifdef _still_not_defined | |
$crap = " from Perl"; | |
$0 = "Hello, World$crap\n"; | |
$NF = "World from awk"; | |
#endif | |
print($0); | |
exit; | |
} | |
#endif | |
#ifdef _i_wont_define_it_so_stop_asking | |
# """; print "Hello, World from Python" # " | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment