0

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.

WilliamKF
  • 7,778
  • 34
  • 103
  • 145
  • 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 01 '11 at 08:45
  • I regenerated with `mkpasswd -c` which resulted in a slightly different entry but same results of sh instead of bash. I also confirmed that `mintty` comes up in sh instead of bash too. – WilliamKF May 01 '11 at 15:00
  • Well, I'm stumped. Probably best to report this to the Cygwin mailing list with the cygcheck details requested at http://cygwin.com/problems.html. Small differences in the SID field (S-1-5-21-...) can be crucial, but I presume you've replaced the entry in question now. Can you actually read `/etc/passwd` as the user that you're trying to run your shell as, i.e. what permissions does `ls -l` show for it? – ak2 May 02 '11 at 11:37
  • Have not tried recently, but last I tried, it was still an issue. – WilliamKF Feb 15 '12 at 22:23

1 Answers1

1

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

Fran
  • 5,313
  • 24
  • 27