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
+5 -1
View File
@@ -247,13 +247,17 @@ int main( int argc, char *argv[] )
string shell_name; string shell_name;
if ( !command_argv ) { if ( !command_argv ) {
/* get shell name */ /* get shell name */
const char *shell = getenv( "SHELL" );
if ( shell == NULL ) {
struct passwd *pw = getpwuid( geteuid() ); struct passwd *pw = getpwuid( geteuid() );
if ( pw == NULL ) { if ( pw == NULL ) {
perror( "getpwuid" ); perror( "getpwuid" );
exit( 1 ); 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 */ if ( shell_path.empty() ) { /* empty shell means Bourne shell */
shell_path = _PATH_BSHELL; shell_path = _PATH_BSHELL;
} }