Restore implicit cd for paths starting with ., .., or ~

This commit is contained in:
ridiculousfish
2012-06-02 14:04:25 -07:00
parent ae12e1b537
commit b7ba252965
6 changed files with 68 additions and 25 deletions

View File

@@ -1956,10 +1956,28 @@ int parser_t::parse_job( process_t *p,
p->actual_cmd = path_get_path( args.at(0).completion.c_str() );
err = errno;
/*
Check if the specified command exists
*/
if( p->actual_cmd == NULL )
bool use_implicit_cd = false;
if (p->actual_cmd == NULL)
{
/* If the specified command does not exist, try using an implicit cd. */
wcstring implicit_cd_path;
use_implicit_cd = path_can_be_implicit_cd(args.at(0).completion, &implicit_cd_path);
if (use_implicit_cd)
{
args.clear();
args.push_back(completion_t(L"cd"));
args.push_back(completion_t(implicit_cd_path));
/* If we have defined a wrapper around cd, use it, otherwise use the cd builtin */
if (use_function && function_exists(L"cd"))
p->type = INTERNAL_FUNCTION;
else
p->type = INTERNAL_BUILTIN;
}
}
/* Check if the specified command exists */
if( p->actual_cmd == NULL && ! use_implicit_cd )
{
int tmp;