Respect SHELL environment variable if set

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg
2014-01-29 19:27:35 -05:00
committed by John Hood
parent 8a91e78349
commit 9019f62bf6
+9 -5
View File
@@ -247,13 +247,17 @@ int main( int argc, char *argv[] )
string shell_name;
if ( !command_argv ) {
/* get shell name */
struct passwd *pw = getpwuid( geteuid() );
if ( pw == NULL ) {
perror( "getpwuid" );
exit( 1 );
const char *shell = getenv( "SHELL" );
if ( shell == NULL ) {
struct passwd *pw = getpwuid( geteuid() );
if ( pw == NULL ) {
perror( "getpwuid" );
exit( 1 );
}
shell = pw->pw_shell;
}
string shell_path( pw->pw_shell );
string shell_path( shell );
if ( shell_path.empty() ) { /* empty shell means Bourne shell */
shell_path = _PATH_BSHELL;
}