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.

  • 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

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").

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.