Show HN: Runc – Compile and run C in one command
This looks fun. I can't imagine it being directly useful but the idea itself is fun.
Couple of immediate issues with the repo:
- Sample output in the README should not be prefixed with a "$". That's only for the shell command prompt.
- Use ``` blocks in your README file. It's easier to format multi-line text.
- Don't use $RANDOM, it's not secure. Use mktemp: https://github.com/alcover/runc/blob/73aaecea5a4cd357f7172dd...
- Don't exit with success if the command failed: https://github.com/alcover/runc/blob/73aaecea5a4cd357f7172dd...
- Use Bash strict mode: http://redsymbol.net/articles/unofficial-bash-strict-mode/
This is not a complaint about the name. Just that as a command from the command line, "runc" may clash with the runc container running utility due to potential overlap in the likely users.
Again, it's not the project name just the potential clash at the OS level. Because over the years, I've done it to myself.
Neat. It wraps GCC.
See also Cling, an interactive C++ interpreter.
Quick and ugly alternative is chmod+x and add something like this to the top of your file:
//$(which gcc) $0 -o a.out; ./a.out $@; rm a.out; exitThis is definitely helpful for testing.
Also related is the tiny C compiler and its `tcc -run` command.
why not call it rungcc, like the FSF t-shirt: https://shop.fsf.org/tshirts-hoodies/run-gcc-shirt
undefined
D has the `rdmd` command for running D code in one command.
Reminds me of [1] "c" a utility which allows you to execute C code as if it were a script. It's a shame the name is almost unsearchable in Google though...
I wrote something similar a few years ago: https://github.com/neilparikh/crepel
I wrote this for a hackathon, so please excuse the messy code :)
This idea has a lot of history behind it. The traditional term is “compile and go”.
I really like Tom Duff's http://www.iq0.com/duffgram/com.html to compile and run in two commands.
Another take on the same idea: https://git.zx2c4.com/cscript/about/
why not just do
gcc main.c && ./a.outWhy is this submission submitted a day ago showing up as new again? @dang