diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6f0183902..3904e660c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -55,6 +55,7 @@ Interactive improvements - The Web-based configuration and documentation now feature a dark mode if the browser requests it (:issue:`8043`). - Color variables can now also be given like ``--background red`` and ``-b red``, not just ``--background=red`` (:issue:`8053`). - ``exit`` run within ``fish_prompt`` now exits properly (:issue:`8033`). +- When attempting to execute the unsupported POSIX-style brace command group (``{ ... }``) fish will suggest its equivalent ``begin; ...; end`` commands (:issue:`6415`). New or improved bindings ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/parse_constants.h b/src/parse_constants.h index 04656dea1..e0e4c52f9 100644 --- a/src/parse_constants.h +++ b/src/parse_constants.h @@ -279,4 +279,8 @@ enum class pipeline_position_t { #define ERROR_TIME_BACKGROUND \ _(L"'time' is not supported for background jobs. Consider using 'command time'.") +/// Error issued on { echo; echo }. +#define ERROR_NO_BRACE_GROUPING \ + _(L"'{ ... }' is not supported for grouping commands. Please use 'begin; ...; end'") + #endif diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp index 439f98035..cd16345fa 100644 --- a/src/parse_execution.cpp +++ b/src/parse_execution.cpp @@ -779,6 +779,10 @@ end_execution_reason_t parse_execution_context_t::handle_command_not_found( } } + if (!cmd_str.empty() && cmd_str.at(0) == L'{') { + error.append(ERROR_NO_BRACE_GROUPING); + } + // Here we want to report an error (so it shows a backtrace). // If the handler printed text, that's already shown, so error will be empty. return this->report_error(STATUS_CMD_UNKNOWN, statement, error.c_str()); diff --git a/tests/checks/command-not-found.fish b/tests/checks/command-not-found.fish index c4c409ac8..748f0bfe5 100644 --- a/tests/checks/command-not-found.fish +++ b/tests/checks/command-not-found.fish @@ -21,4 +21,10 @@ $fish -C 'functions --erase fish_command_not_found' -c 'nonexistent-command appl #CHECKERR: nonexistent-command apple friday #CHECKERR: ^ +{ echo; echo } +# CHECKERR: {{.*}}: Unknown command: '{ echo; echo }' +# CHECKERR: {{.*}}: '{ ... }' is not supported for grouping commands. Please use 'begin; ...; end' +# CHECKERR: { echo; echo } +# CHECKERR: ^ + exit 0