aboutsummaryrefslogtreecommitdiffhomepage
path: root/parser.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-06-02 14:04:25 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-06-02 14:04:25 -0700
commitb7ba2529658e128bfd4b5aacb7702a13c6a9d820 (patch)
tree3242654c8485d7272e0c2a982193cab921873f18 /parser.cpp
parentae12e1b5379d8cee2dd87891670536d01dbce45e (diff)
Restore implicit cd for paths starting with ., .., or ~
Diffstat (limited to 'parser.cpp')
-rw-r--r--parser.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/parser.cpp b/parser.cpp
index b6e03d16..1d91e5b3 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -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;