mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
Unallowed command subst error: add missing newline and simplify
Fixes ommitted newline char shown after complete -n'(foo)' Also axes the 'contains syntax errors' line before the error. Update tests before > complete -n'(foo)' complete: Condition '(foo)' contained a syntax error complete: Command substitutions not allowed⏎ after > complete -n'(foo)' complete: -n '(foo)': command substitutions not allowed here
This commit is contained in:
parent
b2a4a50daf
commit
92698dff48
@ -340,11 +340,11 @@ maybe_t<int> 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<int> builtin_complete(parser_t &parser, io_streams_t &streams, const wch
|
||||
prefix.append(L": ");
|
||||
|
||||
if (maybe_t<wcstring> 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');
|
||||
|
@ -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:
|
||||
|
@ -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'
|
||||
|
@ -325,7 +325,7 @@ $fish -c 'echo {}}'
|
||||
#CHECKERR: echo {}}
|
||||
#CHECKERR: ^
|
||||
printf '<%s>\n' ($fish -c 'command (asd)' 2>&1)
|
||||
#CHECK: <fish: Command substitutions not allowed>
|
||||
#CHECK: <fish: command substitutions not allowed here>
|
||||
#CHECK: <command (asd)>
|
||||
#CHECK: < ^~~~^>
|
||||
true
|
||||
|
@ -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: <fish: Command substitutions not allowed>
|
||||
# CHECK: <(true one)>
|
||||
# CHECK: <^~~~~~~~~^>
|
||||
# CHECK: <fish: command substitutions not allowed here>
|
||||
# CHECK: <FOO=BAR (true one)>
|
||||
# CHECK: < ^~~~~~~~~^>
|
||||
|
||||
$fish -c 'echo "unfinished "(subshell' 2>| string replace -r '.*' '<$0>'
|
||||
# CHECK: <fish: Unexpected end of string, expecting ')'>
|
||||
|
Loading…
x
Reference in New Issue
Block a user