Further changes in builtin.cpp to use env_get_string()

This commit is contained in:
Siteshwar Vashisht 2012-01-10 00:05:51 +05:30
parent 7530057c6e
commit feed900f3d

View file

@ -2613,7 +2613,7 @@ static int builtin_exit( wchar_t **argv )
*/ */
static int builtin_cd( wchar_t **argv ) static int builtin_cd( wchar_t **argv )
{ {
wchar_t *dir_in; wcstring dir_in;
wchar_t *dir; wchar_t *dir;
int res=STATUS_BUILTIN_OK; int res=STATUS_BUILTIN_OK;
void *context = halloc( 0, 0 ); void *context = halloc( 0, 0 );
@ -2621,8 +2621,8 @@ static int builtin_cd( wchar_t **argv )
if( argv[1] == 0 ) if( argv[1] == 0 )
{ {
dir_in = env_get( L"HOME" ); dir_in = env_get_string( L"HOME" );
if( !dir_in ) if( dir_in.empty() )
{ {
sb_printf( sb_err, sb_printf( sb_err,
_( L"%ls: Could not find home directory\n" ), _( L"%ls: Could not find home directory\n" ),
@ -2632,7 +2632,7 @@ static int builtin_cd( wchar_t **argv )
else else
dir_in = argv[1]; dir_in = argv[1];
dir = path_get_cdpath( context, dir_in ); dir = path_get_cdpath( context, dir_in.empty()?0:dir_in.c_str() );
if( !dir ) if( !dir )
{ {
@ -2641,21 +2641,21 @@ static int builtin_cd( wchar_t **argv )
sb_printf( sb_err, sb_printf( sb_err,
_( L"%ls: '%ls' is not a directory\n" ), _( L"%ls: '%ls' is not a directory\n" ),
argv[0], argv[0],
dir_in ); dir_in.c_str() );
} }
else if( errno == ENOENT ) else if( errno == ENOENT )
{ {
sb_printf( sb_err, sb_printf( sb_err,
_( L"%ls: The directory '%ls' does not exist\n" ), _( L"%ls: The directory '%ls' does not exist\n" ),
argv[0], argv[0],
dir_in ); dir_in.c_str() );
} }
else if( errno == EROTTEN ) else if( errno == EROTTEN )
{ {
sb_printf( sb_err, sb_printf( sb_err,
_( L"%ls: '%ls' is a rotten symlink\n" ), _( L"%ls: '%ls' is a rotten symlink\n" ),
argv[0], argv[0],
dir_in ); dir_in.c_str() );
} }
else else
@ -2663,7 +2663,7 @@ static int builtin_cd( wchar_t **argv )
sb_printf( sb_err, sb_printf( sb_err,
_( L"%ls: Unknown error trying to locate directory '%ls'\n" ), _( L"%ls: Unknown error trying to locate directory '%ls'\n" ),
argv[0], argv[0],
dir_in ); dir_in.c_str() );
} }