Respect SHELL environment variable if set
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
committed by
John Hood
parent
8a91e78349
commit
9019f62bf6
@@ -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 */
|
||||||
struct passwd *pw = getpwuid( geteuid() );
|
const char *shell = getenv( "SHELL" );
|
||||||
if ( pw == NULL ) {
|
if ( shell == NULL ) {
|
||||||
perror( "getpwuid" );
|
struct passwd *pw = getpwuid( geteuid() );
|
||||||
exit( 1 );
|
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 */
|
if ( shell_path.empty() ) { /* empty shell means Bourne shell */
|
||||||
shell_path = _PATH_BSHELL;
|
shell_path = _PATH_BSHELL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user