3 ms·
"Please don't start your shell scripts with #!/bin/sh...run it with '/bin/sh foobar', instead of ./foobar." Are you serious?
by flooha 17y ago
"Please don't start your shell scripts with #!/bin/sh...run it with '/bin/sh foobar', instead of ./foobar."
Are you serious?
- adamc 17y agoHe's making an analogy to the article.
- flooha 17y agoThat's what I was hoping...I guess I prefer my sarcasm a little more heavy handed. lol
- masklinn 17y agoYeah but his analogy is wrong in that /bin/sh is usually a link (or a copy) of the user's shell. So the user can easily configure which shell is loaded and how using /bin/sh (though /usr/bin/env sh would probably be even better). What Ryan's gripping against here is that the people requiring rubygems usually don't care for rubygems itself. They just want to require a library which (on their machine) happens to be managed via rubygems. And this management is not the sole strategy. Somebody else could be using another utility, or even no utility at all if they handle their $LOAD_PATH manually (which Ryan apparently does). And in these cases, requiring rubygems breaks their platform: they might not want or care for rubygems. In any case, it's usually not needed so why require it? And that's Ryan's point: by requiring rubygems when it's not needed (which is most of the time) in your library, you're forcing people to use rubygems whether they like (or need) it or not. Furthremore, his analogy is also wrong because even with a /bin/sh shebang *it's trivial for me to overload it by calling `./mysupershell yourscript`. With `require rubygems` there's no such recourse (apart from `require` hackery or other such crap).
- tptacek 17y agoThe /bin/sh link thing is a Linuxism --- in fact, I think it's a Debianism. On FreeBSD, Solaris, and OS X, /bin/sh is either always Bourne or always Bourne-Again. Also, the link that is there is always to a Bourne shell variant. It's not like your system will run fine with ksh as /bin/sh.
- papercrane 17y agoActually your system should work just fine with ksh as /bin/sh. KornShell is a superset of the Bourne shell. http://www.kornshell.com/doc/faq.html http://www.kornshell.com/doc/faq.html
- tptacek 17y agoOK ksh a bad example.