Significantly improve accuracy of error reporting in the cd builtin

darcs-hash:20070920172928-75c98-826cd86e1c33e1f6c746227655e340a6bb459f30.gz
This commit is contained in:
liljencrantz
2007-09-21 03:29:28 +10:00
parent 64933d31a6
commit 3b39b1fa03
2 changed files with 57 additions and 6 deletions

17
path.c
View File

@@ -137,7 +137,7 @@ wchar_t *path_get_path( void *context, const wchar_t *cmd )
wchar_t *path_get_cdpath( void *context, wchar_t *dir )
{
wchar_t *res = 0;
int err = ENOENT;
if( !dir )
return 0;
@@ -151,6 +151,11 @@ wchar_t *path_get_cdpath( void *context, wchar_t *dir )
{
res = halloc_wcsdup( context, dir );
}
else
{
err = ENOTDIR;
}
}
}
else
@@ -207,11 +212,21 @@ wchar_t *path_get_cdpath( void *context, wchar_t *dir )
halloc_register( context, whole_path );
break;
}
else
{
err = ENOTDIR;
}
}
free( whole_path );
}
free( path_cpy );
}
if( !res )
{
errno = err;
}
return res;
}