0

The default shell for root (at least on Yosemite) is /bin/sh. Would there be any problem to changing it to bash (or better yet zsh)? As far as a I know bash at least is backward compatible.

I need a more robust shell to run things like iTerm's shell integration.

  • How do you become the root user. I use the command sudo bash. – David Anderson Oct 10 '15 at 14:53
  • or sudo -s (which uses the value of $SHELL to spawn a root shell) – nohillside Oct 10 '15 at 14:57
  • After taking a stab at answering this, I'm finding it hard to see what robust shell has to do with a practical problem. Is this hypothetical or are you facing a specific error? – bmike Oct 10 '15 at 15:19
  • If you are looking for help in getting iTerm shell integration working with sh (because you currently get a Your shell, /bin/sh, is not supported yet. Only tcsh, zsh, bash, and fish are supported. Sorry! error when following the instructions on the iTerm site), please ask a new question for this (or consider analyzing the code of the curl'ed scripts and adapting it for sh the entry exam for running root shells :-)). – nohillside Oct 10 '15 at 15:27
  • 1
    @patrix nailed it - Q:"when am I ready for a root shell?" A: You will know when the time comes. – bmike Oct 10 '15 at 15:33
1

The path of the shell is the only substantial difference I can see between sh and bash - if you look carefully at /bin/sh on OS X, it's really bash (perhaps compiled with a flag to make it know it's filling in for sh since the binaries are slightly different).

mac me$ md5 /bin/sh /bin/bash
MD5 (/bin/sh) = 2cc3c26641112c1bd0173f396b7d7662
MD5 (/bin/bash) = 5d7583d80e5314ac844eedc6d68c6cd7
mac me $ ls -l /bin/sh /bin/bash
-r-xr-xr-x  1 root  wheel  628496 Aug 28 02:02 /bin/bash
-r-xr-xr-x  1 root  wheel  632672 Aug 28 02:02 /bin/sh
mac me $ sh --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.
manoa mac me $ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.

So, if somehow iTerm is barfing on /bin/sh even though it's already bash, you could change shells. I'd say running things from your user with sudo -H is always better than enabling root, but that's a discussion for another thread:

If you want to test the change:

  • 1
    You may be interested in the results of echo $SHELLOPTS between sh and bash, also shopt. The biggest difference between the two is the invocation of rc files. – fd0 Oct 10 '15 at 18:35
  • Well said @fd0 - shopt and $SHELLOPTS are crucial for fixing actual problems with portability of scripts and such. I fear I already am too far down the rabbit hole for a question on working around one tool's check though. – bmike Oct 10 '15 at 19:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .