On a related note, how about C source code that you can chmod +x and execute directly, even with execve: https://gist.github.com/jdarpinian/84a28a1ed8a36313a4e0cad8b...
https://gist.github.com/jdarpinian/1952a58b823222627cc1a8b83...
Neat though, and I haven't seen it before.
https://docs.google.com/document/d/1sBzur57FeLqzgcoGMz8jwOgM...
Challenge accepted. :-) Might be just a matter of a shebang at the beginning and an 'exec' before the final $p.
I now remember why I used the complicated expr command and make; it's to ensure it works with C and C++.
And any language that happens to accept // as a comment and is supported by "make". (note that no actual Makefile is required)
#!/usr/bin/tcc -run #include <stdio.h> int main() { puts("Hello, World!"); }
$ cat >test.c
//usr/bin/gcc "$0" -o /tmp/out.exe || exit; exec /tmp/out.exe "$@"
#include <stdio.h>
void main(int argc, char **argv) {
printf("Hello, world!");
}
^D
$ chmod a+x test.c
$ ./test.c
Hello, world! //usr/bin/make -s "${0%.*}"&&exec "${0%.*}" "$@";exit