[patch] invoking user's preferred shell from cygwin.bat

Michael Wardle michael@endbracket.net
Thu Mar 24 08:03:00 GMT 2005


Hi

As you will know, the default Cygwin shortcuts invoke "cygwin.bat" which 
in turn runs "bash --login".

On most of my Unix accounts, I have tcsh set as my login shell, and have 
also started to find zsh quite useful, therefore I would prefer to be 
able to set my preferred shell in Cygwin as well.  Most Unix systems do 
this with the pw_shell field of the password database, /etc/passwd.

I have attached a simple C source file which tries to use the user's 
shell if it's specified in the password database.  You might compile 
this and make it available with a name such as /bin/shell and change 
cygwin.bat to invoke "shell" instead of "bash --login".

Design decisions:
- falls back to the default shell rather than exiting if a user
   doesn't exist since Cygwin doesn't currently require a valid
   user account
- uses the default shell if the shell field in /etc/passwd is blank
   as many other Unixes do
- uses /bin/bash as the default shell since cygwin.bat uses that
   as the default

Features:
- sets argv[0] to the shell's basename prefixed by a hyphen/minus
   character which makes most common shells switch to "login" mode

I hope you find it useful.

-- 
Michael Wardle
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: shell.c
URL: <http://cygwin.com/pipermail/cygwin/attachments/20050324/fadb6ccf/attachment.c>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list