From 7df70e18f4511b4fce7fe016d5263ed3025faf78 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 18 Nov 2023 12:24:58 +0100 Subject: [PATCH] Add hint to error message about cmdsub in command position We might end up allowing this but let's add some help for now. See #5575 --- fish-rust/src/expand.rs | 2 +- tests/checks/expansion.fish | 2 +- tests/checks/syntax-error-location.fish | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fish-rust/src/expand.rs b/fish-rust/src/expand.rs index db27ad23d..ae6373d78 100644 --- a/fish-rust/src/expand.rs +++ b/fish-rust/src/expand.rs @@ -1347,7 +1347,7 @@ impl<'a, 'b, 'c> Expander<'a, 'b, 'c> { self.errors, start, end, - "command substitutions not allowed here" + "command substitutions not allowed in command position. Try var=(your-cmd) $var ..." ); } return ExpandResult::make_error(STATUS_EXPAND_ERROR.unwrap()); diff --git a/tests/checks/expansion.fish b/tests/checks/expansion.fish index 2f72e24f6..d1bf5180d 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 7bc53e4cd..9821d752d 100644 --- a/tests/checks/syntax-error-location.fish +++ b/tests/checks/syntax-error-location.fish @@ -25,7 +25,7 @@ FOO=BAR (true one) # more things ' | $fish 2>| string replace -r '(.*)' '<$1>' -# CHECK: +# CHECK: # CHECK: # CHECK: < ^~~~~~~~~^>