5 ms·
If shell were a brand new language, made in someone's basement, it would be immediately shat upon. But its ecology and ubiquity make it 'good enough'. But reall
by lysol 15y ago
If shell were a brand new language, made in someone's basement, it would be immediately shat upon. But its ecology and ubiquity make it 'good enough'. But really, shell programming is awesome in its simplicity. Bash syntax is a bit clumsy but every commandline application ever written for unix is a new library, provided it spits out reasonably predictable output. If unix applications are hunks of oddly-shaped and designed metal, shell programming is the arc welder. (Yes, I know I'm blurring the line between bash, sh, zsh, and the like, but they serve the same purpose.)
- holman 15y agoI've been saying more and more that "I hate shell almost as much as I love it" for those same reasons you mentioned. The syntax is so horrible while at the same time it's so powerful and clear and... lovely. Maybe I'm just strange, but even as a Rubyist who tends to get pedantic about loving clear syntax, I'm starting to really dig shell.
- richcollins 15y agoI'm not sure I'd say that Ruby has a clear syntax. It's better than its predecessor, Perl, but there is a reason everyone uses the same parser code when they start a new Ruby VM -- it's a complicated mess. You certainly can write Ruby with a subset of its syntax that isn't a mess, but no one does. See Scheme and Io for examples of clear, simple syntax.
- aangjie 15y agoAgreed. I haven't learnt ruby properly just read some code trying to fix a bug, but am no fan of ruby syntax. Neither am I of shell, but then shell is ubiquitous.And don't even get me started on perl :-). Ofcourse, my favourite language(syntax-wise) is python so far.
- bitops 15y agoI'm waiting for all the Java-bashing Rubyists out there to discover csh. If you need to do "real programming" csh is pretty great and has a more "programmery" syntax than a lot of the others. But, YMMV.
- jleader 15y agoWay back when I was young and first learning shell scripting, I was taught not to use csh for scripting. Is that no longer true? Have the problems described here http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ been fixed in newer versions of csh, or in tcsh?
- bitops 15y agoOkay, I'll take the bait. When I ssh into our Solaris server, it drops me into csh by default. That makes me think someone out there believes it's good enough.
- artsrc 15y agoThat article is focused on writing scripts, rather than interactive use.
- zdw 15y agoThat's not the default (/bin/sh is on recent versions of Solaris, which is fairly primitive), so your sysadmin is probably the person who thinks it's "good enough". Nearly all Solaris systems I've worked on and set up have a sun freeware or CSW system set up on them with all the standard "linuxy" tools installed, so the change isn't that weird.
- bitops 15y agoThis was on a Sun Fire X4500 box set up by a sysadmin who I know for sure is not a csh guy. Could be that it was different for some reason.
- LukeShu 15y agoSolaris is more BSD based than AT&T-UNIX based; csh is the historic choice for BSD, and most BSD-descendants honor this, as it is what BSD users expect. For example, it is the default user shell on FreeBSD. But the system shell is a Bourne-like shell (ash, I believe?). So for serious usage, even the modern BSDs defer to a Bourne shell.
- Goladus 15y agoThe thing is about the shell is that it can't really be a brand new language. The shell derives its power directly from the OS and the OS needs the shell to provide much of that power. They almost have to evolve together. Also, bash syntax seems a lot less clumsy once you grok unix stuff like pipes, exit codes, and argument parsing (which you should really do anyway before scripting unix in any language). The fundamental abstraction is the command + argument list, and many quirks clearly derive from the syntax trying to stay out of the way of executing commands and gathering the results.
- 1amzave 15y ago> The shell derives its power directly from the OS Indeed. After using it for quite some time without really thinking about it much, I've only relatively recently come to the realization that the shell is, in many ways, simply a thin very UI layer wrapped around the kernel's syscall API, and I think the awesome utility of the shell speaks to the quality of the design of that API.
- Dobbs 15y agoThe shell's name is derived from the fact that it was a wrapper around the kernel.