Move $nu.env to $env (#665)

* Move env from nu builtin to its own

* update samples/tests
This commit is contained in:
JT
2022-01-05 08:34:42 +11:00
committed by GitHub
parent 4d1ce6c27b
commit 8f6843c600
11 changed files with 95 additions and 80 deletions

View File

@ -495,10 +495,10 @@ pub fn parse_module_block(
// TODO: Exported env vars are usable iside the module only if correctly
// exported by the user. For example:
//
// > module foo { export env a { "2" }; export def b [] { $nu.env.a } }
// > module foo { export env a { "2" }; export def b [] { $env.a } }
//
// will work only if you call `use foo *; b` but not with `use foo; foo b`
// since in the second case, the name of the env var would be $nu.env."foo a".
// since in the second case, the name of the env var would be $env."foo a".
b"export" => {
let (stmt, exportable, err) =
parse_export(working_set, &pipeline.commands[0].parts);

View File

@ -1331,6 +1331,16 @@ pub fn parse_variable_expr(
},
None,
);
} else if contents == b"$env" {
return (
Expression {
expr: Expr::Var(nu_protocol::ENV_VARIABLE_ID),
span,
ty: Type::Unknown,
custom_completion: None,
},
None,
);
}
let (id, err) = parse_variable(working_set, span);