mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-14 03:42:44 +08:00
Fix inconsistent error message on quoted keyword
Commit bdfbdaafcc
(Forbid subcommand keywords in variables-as-commands
(#10249), 2024-02-06) banned "set x command; $x foo" because the
parser will not recognize "$x" as decorator.
That means that we would execute only the builtin stub,
which usually exist only for the --help argument.
This scenario does not apply for keywords that are quoted or contain
line continuations. We should not treat «"command"» differently
from «command». Fix this inconsistency to reduce confusion.
This commit is contained in:
parent
6d18f57e96
commit
debfdf0a39
|
@ -1,7 +1,8 @@
|
|||
//! Provides the "linkage" between an ast and actual execution structures (job_t, etc.).
|
||||
|
||||
use crate::ast::{
|
||||
self, BlockStatementHeaderVariant, Keyword, Leaf, List, Node, StatementVariant, Token,
|
||||
self, unescape_keyword, BlockStatementHeaderVariant, Keyword, Leaf, List, Node,
|
||||
StatementVariant, Token,
|
||||
};
|
||||
use crate::builtins;
|
||||
use crate::builtins::shared::{
|
||||
|
@ -44,7 +45,7 @@ use crate::reader::fish_is_unwinding_for_exit;
|
|||
use crate::redirection::{RedirectionMode, RedirectionSpec, RedirectionSpecList};
|
||||
use crate::signal::Signal;
|
||||
use crate::timer::push_timer;
|
||||
use crate::tokenizer::{variable_assignment_equals_pos, PipeOrRedir};
|
||||
use crate::tokenizer::{variable_assignment_equals_pos, PipeOrRedir, TokenType};
|
||||
use crate::trace::{trace_if_enabled, trace_if_enabled_with_args};
|
||||
use crate::wchar::{wstr, WString, L};
|
||||
use crate::wchar_ext::WExt;
|
||||
|
@ -538,7 +539,10 @@ impl<'a> ExecutionContext {
|
|||
// which won't be doing what the user asks for
|
||||
//
|
||||
// (skipping in no-exec because we don't have the actual variable value)
|
||||
if !no_exec() && parser_keywords_is_subcommand(out_cmd) && unexp_cmd != out_cmd {
|
||||
if !no_exec()
|
||||
&& &unescape_keyword(TokenType::string, unexp_cmd) != out_cmd
|
||||
&& parser_keywords_is_subcommand(out_cmd)
|
||||
{
|
||||
return report_error!(
|
||||
self,
|
||||
ctx,
|
||||
|
|
|
@ -341,6 +341,11 @@ echo foo | $pager
|
|||
#CHECKERR: echo foo | $pager
|
||||
#CHECKERR: ^~~~~^
|
||||
|
||||
"command" -h
|
||||
#CHECKERR: fish: command: missing man page
|
||||
#CHECKERR: Documentation may not be installed.
|
||||
#CHECKERR: `help command` will show an online version
|
||||
|
||||
echo {~,asdf}
|
||||
# CHECK: /{{.*}} asdf
|
||||
echo {asdf,~}
|
||||
|
|
Loading…
Reference in New Issue
Block a user