Skip to content

Commit 8f7ce41

Browse files
author
Lisa Ugray
authored
Merge pull request #107 from MartyBeGood/master
Allow user to turn off "shadowenv [de]activated" prompts
2 parents b625a2b + 2832f8d commit 8f7ce41

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/output.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::features::Feature;
22
use crate::loader;
33
use crate::trust;
44

5-
use atty::{isnt, Stream};
5+
use atty::{is, Stream};
66
use failure::{format_err, Error};
77
use regex::Regex;
88
use std::collections::HashSet;
@@ -38,7 +38,7 @@ pub fn handle_hook_error(err: Error, shellpid: u32, silent: bool) -> i32 {
3838
}
3939

4040
pub fn print_activation_to_tty(activated: bool, features: HashSet<Feature>) {
41-
if isnt(Stream::Stderr) {
41+
if !should_print_activation() {
4242
return;
4343
}
4444
if activated {
@@ -141,3 +141,15 @@ fn create_cooldown_sentinel(path: PathBuf) -> Result<(), Error> {
141141
.open(path)?;
142142
Ok(())
143143
}
144+
145+
fn should_print_activation() -> bool {
146+
let configured_to_print: bool;
147+
match env::var("SHADOWENV_SILENT") {
148+
Ok(value) => match value.to_lowercase().as_str() {
149+
"0" | "false" | "no" | "" => configured_to_print = true,
150+
_ => configured_to_print = false,
151+
},
152+
Err(_) => configured_to_print = true,
153+
};
154+
return is(Stream::Stderr) && configured_to_print;
155+
}

0 commit comments

Comments
 (0)