mirror of
https://github.com/nushell/nushell
synced 2025-01-14 14:14:13 +00:00
Merge pull request #884 from jonathandturner/nu_path_var
Add support for $nu:path
This commit is contained in:
commit
17ad07ce27
2 changed files with 24 additions and 7 deletions
|
@ -589,17 +589,22 @@ impl Command {
|
||||||
out.to_output_stream()
|
out.to_output_stream()
|
||||||
} else {
|
} else {
|
||||||
let nothing = Value::nothing().tagged(Tag::unknown());
|
let nothing = Value::nothing().tagged(Tag::unknown());
|
||||||
|
|
||||||
let call_info = raw_args
|
let call_info = raw_args
|
||||||
.clone()
|
.clone()
|
||||||
.call_info
|
.call_info
|
||||||
.evaluate(®istry, &Scope::it_value(nothing.clone()))
|
.evaluate(®istry, &Scope::it_value(nothing.clone()));
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
match command
|
match call_info {
|
||||||
.run(&call_info, ®istry, &raw_args, nothing)
|
Ok(call_info) => {
|
||||||
.into()
|
match command
|
||||||
{
|
.run(&call_info, ®istry, &raw_args, nothing)
|
||||||
Ok(o) => o,
|
.into()
|
||||||
|
{
|
||||||
|
Ok(o) => o,
|
||||||
|
Err(e) => OutputStream::one(Err(e)),
|
||||||
|
}
|
||||||
|
}
|
||||||
Err(e) => OutputStream::one(Err(e)),
|
Err(e) => OutputStream::one(Err(e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,6 +177,18 @@ fn evaluate_reference(
|
||||||
let config = crate::data::config::read(tag.clone(), &None)?;
|
let config = crate::data::config::read(tag.clone(), &None)?;
|
||||||
Ok(Value::row(config).tagged(tag))
|
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
|
x => Ok(scope
|
||||||
.vars
|
.vars
|
||||||
.get(x)
|
.get(x)
|
||||||
|
|
Loading…
Reference in a new issue