mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 09:25:38 +02:00
Alias to keywords (eg source
) (#4835)
* Allow aliasing source * Add test
This commit is contained in:
@ -897,10 +897,19 @@ pub fn parse_call(
|
||||
new_spans.extend(&spans[(pos + 1)..]);
|
||||
}
|
||||
|
||||
working_set.enter_scope();
|
||||
working_set.hide_alias(&name);
|
||||
let (mut result, err) = parse_expression(working_set, &new_spans, false);
|
||||
working_set.exit_scope();
|
||||
let alias_id = working_set.hide_alias(&name);
|
||||
let lite_command = LiteCommand {
|
||||
comments: vec![],
|
||||
parts: new_spans.clone(),
|
||||
};
|
||||
let (mut result, err) = parse_builtin_commands(working_set, &lite_command);
|
||||
if let Some(frame) = working_set.delta.scope.last_mut() {
|
||||
if let Some(alias_id) = alias_id {
|
||||
frame.aliases.insert(name.clone(), alias_id);
|
||||
}
|
||||
}
|
||||
|
||||
let mut result = result.expressions.remove(0);
|
||||
|
||||
result.replace_span(working_set, expansion_span, orig_span);
|
||||
|
||||
|
Reference in New Issue
Block a user