mirror of
https://github.com/nushell/nushell.git
synced 2025-08-16 16:01:55 +02:00
Allow captured stderr saving to file (#6793)
* support redirect stderr to file * fix test * fix test * fix test
This commit is contained in:
@ -292,7 +292,8 @@ fn main() -> Result<()> {
|
||||
if let Some(testbin) = &binary_args.testbin {
|
||||
// Call out to the correct testbin
|
||||
match testbin.item.as_str() {
|
||||
"echo_env" => test_bins::echo_env(),
|
||||
"echo_env" => test_bins::echo_env(true),
|
||||
"echo_env_stderr" => test_bins::echo_env(false),
|
||||
"cococo" => test_bins::cococo(),
|
||||
"meow" => test_bins::meow(),
|
||||
"meowb" => test_bins::meowb(),
|
||||
|
@ -11,11 +11,15 @@ use nu_protocol::{CliError, PipelineData, Span, Value};
|
||||
/// Echo's value of env keys from args
|
||||
/// Example: nu --testbin env_echo FOO BAR
|
||||
/// If it it's not present echo's nothing
|
||||
pub fn echo_env() {
|
||||
pub fn echo_env(to_stdout: bool) {
|
||||
let args = args();
|
||||
for arg in args {
|
||||
if let Ok(v) = std::env::var(arg) {
|
||||
println!("{}", v);
|
||||
if to_stdout {
|
||||
println!("{}", v);
|
||||
} else {
|
||||
eprintln!("{}", v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user