3 ms·
it's actually much easier than that: https://github.com/kahing/bin/blob/master/cleancache.c https://github.com/kahing/bin/blob/master/cleancache.c
by khc 9y ago
it's actually much easier than that: https://github.com/kahing/bin/blob/master/cleancache.c https://github.com/kahing/bin/blob/master/cleancache.c
- modeless 9y agoTrue, but there are a few gotchas with that version. It won't work with execve, it doesn't cache the binary, it won't work if called with "source", it doesn't set argv[0] properly when the binary is called, and a few other things. It is nice and terse though.
- khc 9y agoexecve and binary caching are relatively easy to implement, as is argv[0]. Do people actually care about making "source" work?
- modeless 9y agoexecve compatibility is not easy at all, since it requires a shebang line which isn't valid C. However thanks to emmelaich's // idea I just figured out a way to do it using fewer lines than your #if 0 solution. https://gist.github.com/jdarpinian/1952a58b823222627cc1a8b83a7aa4e2 https://gist.github.com/jdarpinian/1952a58b823222627cc1a8b83...
- MaxBarraclough 9y agoI can't decide if that's cute, or eye-bleedingly criminal. Neat though, and I haven't seen it before.