Skip to content

Commit

Permalink
Logging around using script from env var
Browse files Browse the repository at this point in the history
  • Loading branch information
tesujimath committed Aug 22, 2024
1 parent e64c749 commit e95c126
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ fn bash_env(
..Default::default()
},
)
.with_context(|| format!("popen({})", script_path))?;
.with_context(|| format!("Popen::create({})", script_path))?;

let (out, err) = p
.communicate(stdin.as_deref())
Expand Down Expand Up @@ -243,12 +243,16 @@ fn main() {

// prefer to take the path from the environment variable, falling back to writing a temporary file
// with contents taken from the embedded script
let script_path_from_env = env::var("NU_PLUGIN_BASH_ENV_SCRIPT").ok();
let script_path_env_var = "NU_PLUGIN_BASH_ENV_SCRIPT";
let script_path_from_env = env::var(script_path_env_var).ok();
#[allow(unused_assignments)]
let mut tempdir: Option<TempDir> = None;

let script_path = match script_path_from_env {
Some(path) => path,
Some(path) => {
debug!("using {} from {}", &path, script_path_env_var);
path
}
None => {
tempdir = Some(TempDir::new().expect("failed to create tempdir for bash script"));
extract_embedded_script(tempdir.as_ref().unwrap())
Expand Down

0 comments on commit e95c126

Please sign in to comment.