Skip to content

Instantly share code, notes, and snippets.

@mohd-akram
Created May 30, 2024 09:01
Show Gist options
  • Save mohd-akram/987c18ceef7689e726d52beb8cc29a48 to your computer and use it in GitHub Desktop.
Save mohd-akram/987c18ceef7689e726d52beb8cc29a48 to your computer and use it in GitHub Desktop.
Execute C files directly
//usr/bin/cc -o ${o=`mktemp`} "$0" && exec -a "$0" "$o" "$@"
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("%s", argv[0]);
for (int i = 1; i < argc; i++)
printf(" %s", argv[i]);
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment