Last active
July 23, 2017 14:40
-
-
Save detomon/e04734c2890fd51b18e3f2109248ec4c to your computer and use it in GitHub Desktop.
Compiling and running a C program in the shell by executing itself as shell script
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
#if 0 | |
clang -Wall -O2 -o /tmp/`basename $0` $0 && /tmp/`basename $0` $@; exit | |
#endif | |
// | |
// sh run-in-shell.c `whoami` | |
// | |
#include <stdio.h> | |
int main(int argc, char const* argv[]) { | |
printf("Hello, %s!\n", argv[1]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment