Which shell do you guys use?

Discussion in 'Mac Programming' started by Cromulent, Sep 10, 2011.

?

Which shell do you use?

  1. ksh

    1 vote(s)
    2.2%
  2. bash

    30 vote(s)
    66.7%
  3. zsh

    3 vote(s)
    6.7%
  4. tcsh

    8 vote(s)
    17.8%
  5. ash

    0 vote(s)
    0.0%
  6. csh

    3 vote(s)
    6.7%
  7. Other (please specify)

    0 vote(s)
    0.0%
  1. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #1
    So just for a bit of fun in the programming forum - which shell do you use? Perhaps include some information about why you use that shell.

    I'm in the process of switching over to the zsh myself simply because I have never really learnt a shell and decided that zsh sounded like it had the most features along with a decent manual so I chose to learn that one.
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    Switching from what? For what reason(s)?

    I'm fine using bash right now, because I don't need any extra power features. Even if I did need them, it might limit the compatibility of shell scripts I have to distribute. The shell scripts were often embedded in other programs, where the presence of the shell script was not plainly obvious to the user, so asking a user to install zsh was a non-starter. bash (or a bash-compatible shell) is practically everywhere.
     
  3. Cromulent thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #3
    I've always used bash since that has been the default on every platform I use. I used ksh for a little bit on OpenBSD but never really used any shell properly.

    The reason for switching is because I decided I needed to learn one shell properly and read some information about all the different shells and the general consensus was that zsh had the most features so I decided if I was going to spend the time learning a shell I might as well choose the one with the most features.
     
  4. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #4
    Interesting approach. Let me present a counter point. You state:
    "I've always used bash since that has been the default on every platform I use"

    So you're passing up ubiquity for some features that you haven't learned yet that you may never need. I guess it's my preference just to use bash because there is almost always bash. I haven't been stymied by a problem that using a different shell would have solved. Also, there's perl. If some shell thing gets too hairy perl is available widely enough that I'll just use that for complex scripting that my knowledge of bash can't address.

    -Lee
     
  5. Hansr macrumors 6502a

    Joined:
    Apr 1, 2007
    #5
    +1

    Don't really need anything more and I'm familiar with what's available.
     
  6. Cromulent, Sep 10, 2011
    Last edited: Sep 10, 2011

    Cromulent thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #6
    True. I've just been learning Vim for the last few months (does it ever stop? :)) and have noticed a huge improvement in my productivity. Especially as I now have all the plugins that help with C and Python programming. I was kind of hoping that spending the time to learn a shell (any shell really) would result in the same kind of productivity improvement and since the next computer I will be buying will be a PC running Linux (just can't justify the expense of another Mac with the specs that I need) I thought I might as well make the effort to start learning now.

    In the past I've just used Python rather than shell scripting but I have at times had to read them which is quite tricky when you don't know the shell scripting language. Also as far as I am aware zsh makes big efforts to remain compatible with the original Bourne shell.
     
  7. chown33, Sep 10, 2011
    Last edited: Sep 10, 2011

    chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #7
    Interesting choice. I would have chosen bash for its ubiquity. It has plenty of powerful features, most of which very few people learn.

    After learning bash well, I might go on to zsh, which is also an enhanced Bourne shell. For me, the key is knowing bash well enough to know what's in bash and what's in other enhanced shells.

    I don't think there's One Shell, just like I don't think there's One Programming Language. I think it's more useful to know several well enough, and be versatile and skilled enough to know when to apply each. If I had to learn zsh, there is no doubt that proficiency in bash would be the best foundation. And a good foundation has no substitute.


    Yes, knowing how to read shell scripts is a necessary skill.

    bash has much more than the original Bourne shell.


    Here's a shell comparison chart:
    http://en.wikipedia.org/wiki/Comparison_of_command_shells

    It might not be detailed enough to see all the differences, but it does show some of the significant ones.
     
  8. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #8
    When I first moved to Mac OS X, I used tcsh. But that's only because I came from FreeBSD and I knew and was comfortable with tcsh. I wasn't a stranger to Bourne shells, it was just that I knew advanced techniques in tcsh that made me more productive.

    This is the point I wanted to make. There's nothing wrong with using Python, if you're productive in it.
     
  9. Cromulent thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #9
    Sure. But there is a lot more to a shell than simply scripting and I feel woefully uneducated in that area.

    I've just bought a book called "Unix Power Tools" which I hope will give me a better understanding of everything (not that I am bad with Unix systems I just know I could be better with a bit of effort).
     
  10. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #10
    It sounds like you really want to be more comfortable and productive at the command line, not with the features of a shell. I think the book you're reading should help. Doing cool things with ssh, awk, grep, wc, at/cron, make, compilers, cat, echo, find, etc. and piping them all together is what allows for so much power. There are definitely interesting things you can do with your shell, but those features aren't my favorite tricks.

    -Lee
     
  11. Cromulent thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #11
    Yeah pretty much, although being more productive with the shell itself wouldn't hurt. I'm not bad when it comes to the main UNIX tools but I'd certainly like to get better at things in general.
     
  12. KnightWRX macrumors Pentium

    KnightWRX

    Joined:
    Jan 28, 2009
    Location:
    Quebec, Canada
    #12
    Here are a few bash tricks that should wet your appetite :

    CTRL+R : recall a command from history. Just start typing and it will match. Hit CTRL+R to scroll through what it found.
    CTRL+S : Stop scrolling. For long running commands with lots of input, you can stop the scrolling while you read a message.
    CTRL+Q : Restart scrolling after a CTRL+S has been issued
    CTRL+Z : Stop running task. Use the bg command to background a task that is stopped, use jobs to list them, fg to bring it back to the foreground.

    CTRL+A : Go to the beginning of the line
    CTRL+E : Go to the end of the line
    CTRL+W : Erase the current or previous word (seperated by whitespace)

    CTRL+C : Send the SIGINT signal

    Up Arrow : Scroll through command history
    Down Arrow : Scroll through command history

    Tab : Complete file names

    Learning an "obscure" shell just to be different is the wrong approach. Learn was is ubiquitous if you want to be versatile. Bash is almost guaranteed to be installed/installable on any Unix systems. Things like the zsh aren't (compiling anything on HP-UX is a challenge for example and finding packages for it isn't always straightforward).

    As an aside : Keep all your shell scripts Bourne shell compatible (/bin/sh) if you really want to make sure they run everywhere. If you use bashisms or other shell built-ins not found in the base Bourne shell specification, you run the chance your script just won't work on some systems. Make use of awk/sed and other Unix utilities to replace the advanced shell built-ins whenever possible and avoid GNU extensions like the plague in scripts (but use them as much as you can when typing commands!).
     
  13. Cromulent thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #13
    I wouldn't say that was my approach at all. I looked at the various shells that were available and based my decision on what I read about them. From reading through the z shell manual it certainly has lots of useful features (particularly in the completion area) that bash supposedly is missing.

    I wouldn't really call the zsh that obscure anyway. Even Apple bundle it with Mac OS X and they hardly do anything for the UNIX users.
     
  14. macrumorsuser10 macrumors 6502

    Joined:
    Nov 18, 2010
    #14
    tcsh all the way!

    I am an experienced software research engineer, and I've been on Unix since 1990. Note that I said Unix, not Linux. I started out working on csh and then moved quickly to tcsh once I discovered it. Occasionally I write some bash scripts, but for day-to-day command-line usage, I use only tcsh.

    Frankly, bash is primitive and repulsive. The only reason people use it is because they don't know any better.

    bash --> Windows --> Honda Civic

    tcsh --> Mac --> Fine German sports sedan


    P.S. I also drive a fine German sports sedan.
     
  15. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #15
    Good old fashion trolling like this rarely ends up on this forum. Bravo! A mention of likely attributes of a bash user's mother would have really topped this with a cherry.

    -Lee
     
  16. KnightWRX macrumors Pentium

    KnightWRX

    Joined:
    Jan 28, 2009
    Location:
    Quebec, Canada
    #16
    It's not on any of my HP-UX and Solaris servers. And if you think Apple hardly does a thing for the UNIX users, you've never used either HP-UX or Solaris. ;)

    But since you seem to really want to be a master "zsh" user, I doubt anything we say will ever change your mind. Have fun doing whatever you want to do. Learning anything is never lost.
     
  17. ratsg macrumors 6502

    Joined:
    Dec 6, 2010
    #17
    C shell && Korne

    I use C shell (tcsh on Macs) as an interactive shell and (primarily) Korne for shell scripting, unless specifically requested to be scripted in another shell.

    A few revisions ago on the Mac, the default shell was changed for some reason from tcsh to bash (easily reverted).

    I work in a multi Unix environment (i.e. Solaris, Mac OS X, AIX, Irix, etc..), and the bash shell usually causes me the most problems, especially when coming from linux system admins. Linux doesn't have a real Borne shell, and /sbin/sh is usually symlink'ed to bash on said systems.

    This frequently causes problems when linux admins write scripts that need to be ran on other Unix/Unix clone systems. Bash scripts, unless they are very simple/basic, are not backward compatible and will not run under a real Borne shell.
     
  18. KnightWRX macrumors Pentium

    KnightWRX

    Joined:
    Jan 28, 2009
    Location:
    Quebec, Canada
    #18
    My SAP Basis friends have a few examples where C shell scripts exhibit the same behavior as tcsh and csh are not quite compatible. At least Bash is fully Bourne Shell compatible so if you stick to strick Bourne shell behavior, your scripts will run everywhere. With tcsh and csh it isn't quite so clear cut.

    Heck they even asked me to install the real "csh" unto Linux... I told them to rework their scripts instead.
     
  19. ratsg macrumors 6502

    Joined:
    Dec 6, 2010
    #19
    I am sure that there are more than just a few. C shell has not been updated in over a decade. TCSH continues to be developed and refined today.

    Please let me iterate my opening comment. I use C shell primarily as an interactive shell. Most of my shell scripting is done in Korn.


    Odd, that's the very reason I avoid bash, lack of backward compatibility.

    I know you are poking fun here, but you probably gave them some good advice. The shell scripts I have written in C shell were not very extensive. Korn is a much better choice for an all out massive shell script.

    I don't know what you do in your line of work, but I do network and Unix administration. I am not going to write the next Word Perfect or Lotus 123. And even if I was, the one thing I know for certain is that the work wouldn't be done as a shell script.

    Unix shells are, and should be a religious thing. You should have your favorite, depending on personal preferences and the requirements of your job. With that said, there is nothing wrong with knowing a little bit about most or all of them, and to understand their respective strengths and weaknesses.
     
  20. Cromulent thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #20
    It is interesting to see from the results just how popular bash is amongst developers.
     
  21. Eric S. macrumors 68040

    Eric S.

    Joined:
    Feb 1, 2008
    Location:
    Santa Cruz Mountains, California
  22. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #22
    That's probably because it's the default shell. Back when tcsh (?) was the default, I think the poll would have looked different.


    Why are people still using csh instead of tcsh?
     
  23. Eric S. macrumors 68040

    Eric S.

    Joined:
    Feb 1, 2008
    Location:
    Santa Cruz Mountains, California
    #23
    I can't claim any other reason than force of habit.
     

Share This Page