mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-07-01 08:11:14 -03:00
Support "$(cmd)" command substitution without line splitting
This adds a hack to the parser. Given a command echo "x$()y z" we virtually insert double quotes before and after the command substitution, so the command internally looks like echo "x"$()"y z" This hack allows to reuse the existing logic for handling (recursive) command substitutions. This makes the quoting syntax more complex; external highlighters should consider adding this if possible. The upside (more Bash compatibility) seems worth it. Closes #159
This commit is contained in:
@@ -5103,8 +5103,7 @@ static void test_error_messages() {
|
||||
{L"echo foo\"$\"bar", ERROR_NO_VAR_NAME},
|
||||
{L"echo \"foo\"$\"bar\"", ERROR_NO_VAR_NAME},
|
||||
{L"echo foo $ bar", ERROR_NO_VAR_NAME},
|
||||
{L"echo foo$(foo)bar", ERROR_BAD_VAR_SUBCOMMAND1},
|
||||
{L"echo \"foo$(foo)bar\"", ERROR_BAD_VAR_SUBCOMMAND1}};
|
||||
{L"echo foo$(foo)bar", ERROR_BAD_VAR_SUBCOMMAND1}};
|
||||
|
||||
parse_error_list_t errors;
|
||||
for (const auto &test : error_tests) {
|
||||
@@ -5194,6 +5193,16 @@ static void test_highlighting() {
|
||||
{L"|", highlight_role_t::statement_terminator},
|
||||
{L"cat", highlight_role_t::command},
|
||||
});
|
||||
highlight_tests.push_back({
|
||||
{L"true", highlight_role_t::command},
|
||||
{L"\"before", highlight_role_t::quote},
|
||||
{L"$(", highlight_role_t::operat},
|
||||
{L"true", highlight_role_t::command},
|
||||
{L"param1", highlight_role_t::param},
|
||||
{L")", highlight_role_t::operat},
|
||||
{L"after\"", highlight_role_t::quote},
|
||||
{L"param2", highlight_role_t::param},
|
||||
});
|
||||
|
||||
// Redirections substitutions.
|
||||
highlight_tests.push_back({
|
||||
|
||||
Reference in New Issue
Block a user