Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shebangs
#!/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
You can’t perform that action at this time.