Don't call expand_home_directory from within parser_t::test - it may hang

https://github.com/fish-shell/fish-shell/issues/512
This commit is contained in:
ridiculousfish 2013-01-12 12:53:40 -08:00
parent e9c226b8be
commit b32fcc7a8e
3 changed files with 10 additions and 4 deletions

View file

@ -1644,6 +1644,7 @@ int expand_string(const wcstring &input, std::vector<completion_t> &output, expa
{ {
wcstring next = in->at(i).completion; wcstring next = in->at(i).completion;
if (! (EXPAND_SKIP_HOME_DIRECTORIES & flags))
expand_home_directory(next); expand_home_directory(next);

View file

@ -53,7 +53,10 @@ enum
EXPAND_SKIP_PROCESS = 1 << 7, EXPAND_SKIP_PROCESS = 1 << 7,
/** Don't expand jobs (but you can still expand processes). This is because job expansion is not thread safe. */ /** 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; typedef int expand_flags_t;

View file

@ -3061,7 +3061,9 @@ int parser_t::test(const wchar_t * buff,
arg_count=0; arg_count=0;
command = tok_last(&tok); command = tok_last(&tok);
has_command = expand_one(command, EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES);
// 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) if (! has_command)
{ {
command = L""; command = L"";