mirror of
https://github.com/nushell/nushell.git
synced 2025-01-11 08:48:23 +01:00
Improve error message when bash-style alias syntax is mistakenly used (#3995)
This commit is contained in:
parent
51c74eebd0
commit
55eafadf02
@ -2025,6 +2025,24 @@ fn parse_alias(call: &LiteCommand, scope: &dyn ParserScope) -> Option<ParseError
|
|||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if call.parts.get(2).map(|part| part.item.as_str()) != Some("=") {
|
||||||
|
if let Some(equals_span) = [call.parts.get(1), call.parts.get(2)]
|
||||||
|
.iter()
|
||||||
|
.flatten()
|
||||||
|
.filter_map(|part| {
|
||||||
|
part.find('=')
|
||||||
|
.map(|offset| Span::for_char(part.span.start() + offset))
|
||||||
|
})
|
||||||
|
.next()
|
||||||
|
{
|
||||||
|
return Some(ParseError::general_error(
|
||||||
|
"Invalid alias syntax",
|
||||||
|
"Expected space on both sides of =".spanned(equals_span),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if call.parts.len() < 4 {
|
if call.parts.len() < 4 {
|
||||||
return Some(ParseError::mismatch("alias", call.parts[0].clone()));
|
return Some(ParseError::mismatch("alias", call.parts[0].clone()));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user