Merge pull request #884 from jonathandturner/nu_path_var

Add support for $nu:path
This commit is contained in:
Jonathan Turner 2019-10-29 08:23:02 +13:00 committed by GitHub
commit 17ad07ce27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 7 deletions

View file

@ -589,17 +589,22 @@ impl Command {
out.to_output_stream()
} else {
let nothing = Value::nothing().tagged(Tag::unknown());
let call_info = raw_args
.clone()
.call_info
.evaluate(&registry, &Scope::it_value(nothing.clone()))
.unwrap();
.evaluate(&registry, &Scope::it_value(nothing.clone()));
match command
.run(&call_info, &registry, &raw_args, nothing)
.into()
{
Ok(o) => o,
match call_info {
Ok(call_info) => {
match command
.run(&call_info, &registry, &raw_args, nothing)
.into()
{
Ok(o) => o,
Err(e) => OutputStream::one(Err(e)),
}
}
Err(e) => OutputStream::one(Err(e)),
}
}

View file

@ -177,6 +177,18 @@ fn evaluate_reference(
let config = crate::data::config::read(tag.clone(), &None)?;
Ok(Value::row(config).tagged(tag))
}
x if x == "nu:path" => {
let mut table = vec![];
match std::env::var_os("PATH") {
Some(paths) => {
for path in std::env::split_paths(&paths) {
table.push(Value::path(path).tagged(&tag));
}
}
_ => {}
}
Ok(Value::table(&table).tagged(tag))
}
x => Ok(scope
.vars
.get(x)