Ken Ingram
Ken Ingram

Reputation: 1598

How do I get Cygwin xterm to use bash and not sh?

Just updated cygwin to 1.7.28 on Windows 7.

Previously when starting X, the xterm would open with bash. For some reason it is now opening with sh? What configuration changes do I need to make so that bash is the default shell again? Not sure why this change happened.

The shortcut to open the xterm is the same as it was during my initial installation.

 C:\cygwin\bin\run.exe /usr/bin/bash.exe -l -c /usr/bin/startxwin.exe

But it still starts with the default shell set to sh. I don't understand what changed.

My passwd file is the same as it was before.

It appears that everything starts fine with the standard shortcuts, but the X and xterm startups are not sourcing /etc/profile

Upvotes: 3

Views: 4535

Answers (5)

stevesliva
stevesliva

Reputation: 5665

I had the same issue with sh launching, but managed a different workaround after having issues with /etc/shells

I also wanted to get rid of the default white /bin/sh xterm that startxwin.exe created.

It turns out there's a .startxwinrc that startxwin.exe sources, so I had it do this:

# Launch prettier xterms with bash
. ./.profile

# Exit the cruddy white xterm launched by startxwin
exit

The dot-space syntax above is equivalent to "source" in bash, but is more shell-independent.

Upvotes: 0

jcockrel
jcockrel

Reputation: 61

I had /etc/shells already (upgraded from ??? to 1.7.29), might have been new with upgrade, but still didn't work (xterm running sh instead of bash). Changed permissions on bash to fix.

It was 700 changed to 755

chmod 755 /bin/bash

Upvotes: 5

Chris Baker
Chris Baker

Reputation: 46

xterm seems to need the /etc/shells file to be present to work. Add an /etc/shells file with the following contents:

# /etc/shells: valid login shells
/bin/csh
/bin/sh
/bin/bash
/bin/tcsh
/usr/bin/csh
/usr/bin/sh
/usr/bin/bash
/usr/bin/tcsh

Chris

Upvotes: 3

Sandeep
Sandeep

Reputation: 608

Run following command to set bash as default shell.

set shell=C:/cygwin/bin/bash

Note path C:/cygwin/bin/bash may vary.

Upvotes: 1

Stephen Quan
Stephen Quan

Reputation: 25966

(Removed answer regarding /etc/passwd)

I tried your command on my cygwin and got the same behavior, i.e. xterm loaded with /bin/sh.

However, if I simply ran startxwin.exe directly, I get an xterm loaded with /bin/bash.

Dunno if this works for you, but, worth a try.

Upvotes: 0

Related Questions