From 499d6c6ac5462370eb0576cd1c4212b5cc86df38 Mon Sep 17 00:00:00 2001 From: Valerie Date: Wed, 9 Aug 2023 17:33:34 -0400 Subject: [PATCH] non-terminal use now forces path behavior --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 6261a2e..bf1f3a6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ use std::{ env::{ current_dir, var }, error::Error, fs::read_to_string, + io::{ stdout, IsTerminal }, path::PathBuf, process::{ Command, @@ -81,6 +82,8 @@ fn main() -> Result<(), Box>{ if target.is_none() { error::no_args(); } + let is_terminal = stdout().is_terminal(); + let prop_path = section.get("path"); // handle dir flag if flag_dir { @@ -100,7 +103,7 @@ fn main() -> Result<(), Box>{ return Ok(()); } // handle path flag - if flag_path { + if flag_path || !is_terminal { if prop_path.is_none() { error::no_property(&fullname, "path"); } let i_file_path = prop_path.unwrap().as_str().unwrap(); let file_path = if i_file_path.starts_with("~") { i_file_path.replace("~", &home_dir) } else { i_file_path.to_string() };