aboutsummaryrefslogtreecommitdiffhomepage
path: root/builtin.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-07-20 22:11:05 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-07-20 22:11:05 -0700
commit261bf12c91286ffca9fcb0bf761d6d1666359dc7 (patch)
tree4b6d388843bad1aadae666fa8597c9f0d50488b0 /builtin.cpp
parentb08fb866378693d2e75f17fdfe5e60401a29136a (diff)
Lots of miscellaneous cleanup. Unified the path_get_cd_path, path_allocate_cd_path, etc. functions
Diffstat (limited to 'builtin.cpp')
-rw-r--r--builtin.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/builtin.cpp b/builtin.cpp
index 36b8ec7a..401f4c0c 100644
--- a/builtin.cpp
+++ b/builtin.cpp
@@ -2591,7 +2591,7 @@ static int builtin_exit( parser_t &parser, wchar_t **argv )
static int builtin_cd( parser_t &parser, wchar_t **argv )
{
env_var_t dir_in;
- wchar_t *dir = NULL;
+ wcstring dir;
int res=STATUS_BUILTIN_OK;
@@ -2609,11 +2609,13 @@ static int builtin_cd( parser_t &parser, wchar_t **argv )
dir_in = argv[1];
}
- if (! dir_in.missing()) {
- dir = path_allocate_cdpath(dir_in);
+ bool got_cd_path = false;
+ if (! dir_in.missing())
+ {
+ got_cd_path = path_get_cdpath(dir_in, &dir);
}
- if( !dir )
+ if( !got_cd_path )
{
if( errno == ENOTDIR )
{
@@ -2665,7 +2667,7 @@ static int builtin_cd( parser_t &parser, wchar_t **argv )
append_format(stderr_buffer,
_( L"%ls: Permission denied: '%ls'\n" ),
argv[0],
- dir );
+ dir.c_str() );
}
else
@@ -2674,7 +2676,7 @@ static int builtin_cd( parser_t &parser, wchar_t **argv )
append_format(stderr_buffer,
_( L"%ls: '%ls' is not a directory\n" ),
argv[0],
- dir );
+ dir.c_str() );
}
if( !get_is_interactive() )
@@ -2690,8 +2692,6 @@ static int builtin_cd( parser_t &parser, wchar_t **argv )
append_format(stderr_buffer, _( L"%ls: Could not set PWD variable\n" ), argv[0] );
}
- free(dir);
-
return res;
}