allow -h flags for export subcommands (#6189)

* allow `-h` flags for `export` subcommands

* remove unnecessary check

* add tests

* fmt
This commit is contained in:
pwygab
2022-08-02 23:26:16 +08:00
committed by GitHub
parent 56069af42d
commit 233afebdf0
3 changed files with 38 additions and 3 deletions

View File

@ -4794,11 +4794,30 @@ pub fn parse_builtin_commands(
b"overlay" => parse_overlay(working_set, &lite_command.parts, expand_aliases_denylist),
b"source" => parse_source(working_set, &lite_command.parts, expand_aliases_denylist),
b"export" => {
if let Some(decl_id) = working_set.find_decl(b"export", &Type::Any) {
let full_decl = if lite_command.parts.len() > 1 {
let sub = working_set.get_span_contents(lite_command.parts[1]);
match sub {
b"alias" | b"def" | b"def-env" | b"env" | b"extern" | b"use" => {
[b"export ", sub].concat()
}
_ => b"export".to_vec(),
}
} else {
b"export".to_vec()
};
if let Some(decl_id) = working_set.find_decl(&full_decl, &Type::Any) {
let parsed_call = parse_internal_call(
working_set,
lite_command.parts[0],
&lite_command.parts[1..],
if full_decl == b"export" {
lite_command.parts[0]
} else {
span(&lite_command.parts[0..2])
},
if full_decl == b"export" {
&lite_command.parts[1..]
} else {
&lite_command.parts[2..]
},
decl_id,
expand_aliases_denylist,
);