5 ms·
You can make this do path-searching for make, rather than force it to be in /usr/bin, with //bin/true; make -s "${0%.c}" && ./"${0%.c}" "$@"; s=$?; rm ./"$
by jimrandomh 12y ago
You can make this do path-searching for make, rather than force it to be in /usr/bin, with
//bin/true; make -s "${0%.c}" && ./"${0%.c}" "$@"; s=$?; rm ./"${0%.c}"; exit $s
Which might matter for some platforms, since 'make' isn't usually something that gets the shebang treatment.
- lambda 12y agoI thought of that, and even tried it, but on Mac OS X it's in /usr/bin/true, while on my Debian system it's /bin/true, defeating the purpose of making this path independent. I considered a few no-ops, like /bin/cat (but that would then consume stdin) or /bin/echo -n, but there may be cases in which these can't be relied on either, so I figured that just keeping it simple but relying on the location of make was the better option.
- VanillaCafe 12y agoWhy not just /usr/bin/env make
- lambda 12y agoSure, you can do that. I didn't because it's (a) longer (and I was trying to do some minor golfing to keep it under 80 characters) and (b) doesn't have any stronger of a guarantee that it will be located in /usr/bin than make does. There's more than one way to do this. It's just a silly hack; I decided to keep it simpler as the other alternatives didn't seem strictly better.
- throwaway2048 12y agowell /usr/bin/env existing is a mandatory posix thing at least
- lambda 12y agoNope, there are systems in which it's in /bin/env, though you have to go fairly exotic before you find one that doesn't at least have a symlink in /usr/bin. I don't believe POSIX says anything about it http://www.in-ulm.de/~mascheck/various/shebang/#env http://www.in-ulm.de/~mascheck/various/shebang/#env In fact, POSIX doesn't even standardize the shebang at all; it is simply mentioned as a possible extension.