1

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.

bmike
  • 235,889
thermans
  • 121
  • 5
  • 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
  • Thanks for the condescending responses bmike and @patrix. I asked a simple question and was hoping for a simple answer. You added nothing other than discouraging yet another StackExchange user. Might have been better if I had left the last sentence off, but hey. – thermans Oct 10 '15 at 16:04
  • Yikes. I'm not trying to be patronizing or condescending. My apologies if you took it thusly. I was trying to get at the root cause. A simple question isn't ideal per the site - see [help] on the standards to avoid comments being offered to help refine the "ask". Also, I wouldn't have spent the time to construct my answer if I didn't think your question deserved an answer and also to help many others. – bmike Oct 10 '15 at 16:50

1 Answers1

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:

bmike
  • 235,889
  • 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