Skip to content

Commit 1303195

Browse files
committed
Allow user to turn off "shadowenv [de]activated" prompts
1 parent b625a2b commit 1303195

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/output.rs

Lines changed: 11 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,12 @@ 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(_) => configured_to_print = false,
149+
Err(_) => configured_to_print = true,
150+
};
151+
return is(Stream::Stderr) && configured_to_print;
152+
}

0 commit comments

Comments
 (0)