Last active
February 6, 2018 19:03
-
-
Save CRTified/de7da2976a3b4e7f3f66403797655e2e to your computer and use it in GitHub Desktop.
Shebangs
This file contains hidden or 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
#!/usr/bin/env sh | |
#if 0 | |
TMPFILE=$(mktemp); | |
tail -n +10 $0 | gcc -march=native -o $TMPFILE -x c -; | |
$TMPFILE "${@:1}"; | |
RETVAL=$? | |
rm $TMPFILE; | |
exit $RETVAL; | |
#endif | |
#include<stdio.h> | |
int main(int argc, char* argv[]) | |
{ | |
printf("Hello world, I live at %s\nMy params are:\n", argv[0]); | |
for(int i = 0; i < argc; i++) | |
{ | |
printf("argv[%u] = %s\n", i, argv[i]); | |
} | |
return 0; | |
} | |
// $ ./shebang.c foo bar baz | |
// Hello world, I live at /tmp/tmp.r0QcpfUSUv | |
// My params are: | |
// argv[0] = /tmp/tmp.r0QcpfUSUv | |
// argv[1] = foo | |
// argv[2] = bar | |
// argv[3] = baz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment