Skip to content

Commit 720ae4a

Browse files
committed
feat: Add jtt bash-program (jtt bp) to show bash_program()
This adds a `bash-program` subcommand, abbreviated `bp`, to the `gix-testools` program (`jtt`) to check what the `bash_program()` library function gives. This is intended for diagnostic use and should probably not be used in scripting. Currently it shows the quoted debug repreesentation of the path.
1 parent 5133661 commit 720ae4a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/tools/src/main.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
use std::{fs, io, io::prelude::*, path::PathBuf};
22

3+
fn bash_program() -> io::Result<()> {
4+
use std::io::IsTerminal;
5+
if !std::io::stdout().is_terminal() {
6+
eprintln!("warning: `bash-program` subcommand not meant for scripting, format may change");
7+
}
8+
println!("{:?}", gix_testtools::bash_program());
9+
Ok(())
10+
}
11+
312
fn mess_in_the_middle(path: PathBuf) -> io::Result<()> {
413
let mut file = fs::OpenOptions::new().read(false).write(true).open(path)?;
514
file.seek(io::SeekFrom::Start(file.metadata()?.len() / 2))?;
@@ -17,6 +26,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
1726
let mut args = std::env::args().skip(1);
1827
let scmd = args.next().expect("sub command");
1928
match &*scmd {
29+
"bash-program" | "bp" => bash_program()?,
2030
"mess-in-the-middle" => mess_in_the_middle(PathBuf::from(args.next().expect("path to file to mess with")))?,
2131
#[cfg(unix)]
2232
"umask" => umask()?,

0 commit comments

Comments
 (0)