diff --git a/src/builtins/complete.cpp b/src/builtins/complete.cpp index 98b6d6406..f13b5d825 100644 --- a/src/builtins/complete.cpp +++ b/src/builtins/complete.cpp @@ -340,11 +340,11 @@ maybe_t builtin_complete(parser_t &parser, io_streams_t &streams, const wch for (const auto &condition_string : condition) { parse_error_list_t errors; if (parse_util_detect_errors(condition_string, &errors)) { - streams.err.append_format(L"%ls: Condition '%ls' contained a syntax error", cmd, - condition_string.c_str()); for (const auto &error : errors) { - streams.err.append_format(L"\n%ls: ", cmd); - streams.err.append(error.describe(condition_string, parser.is_interactive())); + wcstring prefix(wcstring(cmd) + L": -n '" + condition_string + L"': "); + streams.err.append(error.describe_with_prefix(condition_string, prefix, + parser.is_interactive(), false)); + streams.err.push_back(L'\n'); } return STATUS_CMD_ERROR; } @@ -356,7 +356,7 @@ maybe_t builtin_complete(parser_t &parser, io_streams_t &streams, const wch prefix.append(L": "); if (maybe_t err_text = parse_util_detect_errors_in_argument_list(comp, prefix)) { - streams.err.append_format(L"%ls: Completion '%ls' contained a syntax error\n", cmd, + streams.err.append_format(L"%ls: %ls: contains a syntax error\n", cmd, comp); streams.err.append(*err_text); streams.err.push_back(L'\n'); diff --git a/src/expand.cpp b/src/expand.cpp index d6f091131..88f745958 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -946,7 +946,7 @@ expand_result_t expander_t::stage_cmdsubst(wcstring input, completion_receiver_t } return expand_result_t::ok; case 1: - append_cmdsub_error(errors, start, end, L"Command substitutions not allowed"); + append_cmdsub_error(errors, start, end, L"command substitutions not allowed here"); /* intentionally falls through */ case -1: default: diff --git a/tests/checks/complete.fish b/tests/checks/complete.fish index 42f8845de..ce8a7b07e 100644 --- a/tests/checks/complete.fish +++ b/tests/checks/complete.fish @@ -469,8 +469,7 @@ complete -c thing -x -F # Multiple conditions complete -f -c shot complete -fc shot -n 'test (count (commandline -opc) -eq 1' -n 'test (commandline -opc)[-1] = shot' -a 'through' -# CHECKERR: complete: Condition 'test (count (commandline -opc) -eq 1' contained a syntax error -# CHECKERR: complete: Unexpected end of string, expecting ')' +# CHECKERR: complete: -n 'test (count (commandline -opc) -eq 1': Unexpected end of string, expecting ')' # CHECKERR: test (count (commandline -opc) -eq 1 # CHECKERR: ^ complete -fc shot -n 'test (count (commandline -opc)) -eq 1' -n 'test (commandline -opc)[-1] = shot' -a 'through' diff --git a/tests/checks/expansion.fish b/tests/checks/expansion.fish index 3e178fb00..3723904b0 100644 --- a/tests/checks/expansion.fish +++ b/tests/checks/expansion.fish @@ -325,7 +325,7 @@ $fish -c 'echo {}}' #CHECKERR: echo {}} #CHECKERR: ^ printf '<%s>\n' ($fish -c 'command (asd)' 2>&1) -#CHECK: +#CHECK: #CHECK: #CHECK: < ^~~~^> true diff --git a/tests/checks/syntax-error-location.fish b/tests/checks/syntax-error-location.fish index 6590a7f76..42b06a92d 100644 --- a/tests/checks/syntax-error-location.fish +++ b/tests/checks/syntax-error-location.fish @@ -19,15 +19,15 @@ echo 'true | time false' | $fish 2>| string replace -r '(.*)' '<$1>' echo ' -(true one) +FOO=BAR (true one) (true two) # more things ' | $fish 2>| string replace -r '(.*)' '<$1>' -# CHECK: -# CHECK: <(true one)> -# CHECK: <^~~~~~~~~^> +# CHECK: +# CHECK: +# CHECK: < ^~~~~~~~~^> $fish -c 'echo "unfinished "(subshell' 2>| string replace -r '.*' '<$0>' # CHECK: