aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-01-12 12:53:40 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-01-12 12:53:40 -0800
commitb32fcc7a8ef2857e111fc5daac15558545df912b (patch)
tree9dde17b5138147d6890a7ec4df3885678a16ab2a
parente9c226b8bebe25f54d65a272ccfa7697980d6d28 (diff)
Don't call expand_home_directory from within parser_t::test - it may hang
-rw-r--r--expand.cpp3
-rw-r--r--expand.h5
-rw-r--r--parser.cpp6
3 files changed, 10 insertions, 4 deletions
diff --git a/expand.cpp b/expand.cpp
index 04d4def0..1371a374 100644
--- a/expand.cpp
+++ b/expand.cpp
@@ -1644,7 +1644,8 @@ int expand_string(const wcstring &input, std::vector<completion_t> &output, expa
{
wcstring next = in->at(i).completion;
- expand_home_directory(next);
+ if (! (EXPAND_SKIP_HOME_DIRECTORIES & flags))
+ expand_home_directory(next);
if (flags & ACCEPT_INCOMPLETE)
diff --git a/expand.h b/expand.h
index 1dedf173..a4f7e2ab 100644
--- a/expand.h
+++ b/expand.h
@@ -53,7 +53,10 @@ enum
EXPAND_SKIP_PROCESS = 1 << 7,
/** Don't expand jobs (but you can still expand processes). This is because job expansion is not thread safe. */
- EXPAND_SKIP_JOBS = 1 << 8
+ EXPAND_SKIP_JOBS = 1 << 8,
+
+ /** Don't expand home directories */
+ EXPAND_SKIP_HOME_DIRECTORIES = 1 << 9
};
typedef int expand_flags_t;
diff --git a/parser.cpp b/parser.cpp
index 49f6b62d..af68be8f 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -3061,8 +3061,10 @@ int parser_t::test(const wchar_t * buff,
arg_count=0;
command = tok_last(&tok);
- has_command = expand_one(command, EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES);
- if (!has_command)
+
+ // Pass SKIP_HOME_DIRECTORIES for https://github.com/fish-shell/fish-shell/issues/512
+ has_command = expand_one(command, EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES | EXPAND_SKIP_HOME_DIRECTORIES);
+ if (! has_command)
{
command = L"";
err=1;