Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I get Cygwin to honor the /etc/passwd file and make my default shell bash instead of sh?

I presume it is controlled somehow by windows XP since I had an issue before with permissions and had to regenerate the /etc/passwd file after updating permissions on Win XP for my user id.

share|improve this question
How are you invoking the shell? Also, check that the SHELL variable which would override the /etc/passwd setting, isn't set. – ak2 Apr 30 '11 at 17:56
The SHELL=/bin/bash and it is invoked by emacs via meta-x shell running inside by x window system started by startx – WilliamKF Apr 30 '11 at 18:02
Right. How do you know that you are running /bin/sh instead of /bin/bash? – ak2 Apr 30 '11 at 19:40
Because the prompt is sh-4.1$' and if I execute bash` I get a new prompt of [xp-pro-sp3 ~] ??? – WilliamKF Apr 30 '11 at 21:05
Fair enough. Are you sure your /etc/passwd entry is correct? You can use mkpasswd -c to print an appropriate entry for the current user. Another thing to try is to invoke one of the Cygwin terminals like mintty or rxvt, which invoke your default shell unless told otherwise. If you get bash there, this becomes an emacs issue. – ak2 May 1 '11 at 8:45
up vote 1 down vote accepted

Try putting this code in your ~/.emacs startup file (and restarting Emacs):

(setq shell-file-name "bash"
      explicit-shell-file-name "bash")

You could also temporarilly rename /bin/sh to /bin/sh.hold to be absolutely certain whether Emacs is invoking /bin/sh or /bin/bash. Keep in mind that in certain cases (see the Bash man page) Bash will behave as sh depending on how it is invoked (e.g., if argv[0] is "sh").

share|improve this answer

You must log in to answer this question.

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