Polyglot program
Apr 23, 2021 at 4:54pm Apr 23, 2021 at 4:54pm UTC
Just thought this was interesting; it is a program written in C, PHP, and Bash shell script. I can only run it as C and shell script, I don't know how to run it as PHP. Anyone want to run it in their IDE or whatever and post the output?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#define a /*
#<?php
echo "\010Hello, world!\n";// 2> /dev/null > /dev/null \ ;
// 2> /dev/null; x=a;
$x=5; // 2> /dev/null \ ;
if (($x))
// 2> /dev/null; then
return 0;
// 2> /dev/null; fi
#define e ?>
#define b */
#include <stdio.h>
#define main() int main(void)
#define printf printf(
#define true )
#define function
function main()
{
printf "Hello, world!\n" true /* 2> /dev/null | grep -v true*/ ;
return 0;
}
#define c /*
main
#*/
As C, it outputs:
As shell script, it outputs:
\010Hello, world!\n
polyglot.sh: line 5: a=5: command not found
Hello, world!
Thanks!
max
Topic archived. No new replies allowed.