Fix builtin $var expansion

A special case added for #1252 needed adjustment.

Fixes #5639
This commit is contained in:
Aaron Gyes 2019-02-10 14:14:48 -08:00
parent 1701e2c558
commit 038fea1a47
3 changed files with 7 additions and 2 deletions

View File

@ -1195,9 +1195,10 @@ static bool detect_errors_in_plain_statement(const wcstring &buff_src,
// Check that we don't do an invalid builtin (issue #1252).
if (!errored && decoration == parse_statement_decoration_builtin &&
!builtin_exists(command)) {
expand_one(*unexp_command, 0, null_environment_t{}, parse_errors) &&
!builtin_exists(*unexp_command)) {
errored = append_syntax_error(parse_errors, source_start, UNKNOWN_BUILTIN_ERR_MSG,
command.c_str());
unexp_command->c_str());
}
}
return errored;

View File

@ -9,6 +9,9 @@ $CMD1
set CMD2 echo '(' not expanded again
$CMD2
# Test using variables with the builtin decorator
builtin $CMD1
# Test implicit cd
set CMD3 /usr/bin
$CMD3 && echo $PWD

View File

@ -1,3 +1,4 @@
basic command as variable
( not expanded again
basic command as variable
/usr/bin