aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-08-07 00:31:20 +0200
committerThomas Voss <mail@thomasvoss.com> 2023-08-07 00:31:20 +0200
commitb51d5a20bcb57c058bf0f2dd2510cad645dffbf4 (patch)
treee49ede691dff4c788df05b03abd8bff652d1cfa9 /src
parent648ef8148cf1e6067e1db728bcbbe04ac1faeb1e (diff)
Add an ‘is_terminal’ predicate
Diffstat (limited to 'src')
-rw-r--r--src/main.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 8ac0223..3aa3ffa 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -84,7 +84,7 @@ fn work() -> Result<(), io::Error> {
err!("{e}");
})
})
- .group_by(|b| *b == (b'\0' + b'\n' * !flags.nul as u8));
+ .group_by(|b| is_terminal(&flags, b));
let srcs = srcs
.into_iter()
.filter(|(x, _)| !x)
@@ -266,7 +266,7 @@ fn run_multi(
err!("{e}");
})
})
- .group_by(|b| *b == (b'\0' + b'\n' * !flags.nul as u8));
+ .group_by(|b| is_terminal(flags, b));
groups
.into_iter()
.filter_map(|(x, y)| match x {
@@ -395,3 +395,7 @@ fn copy_and_remove_file_or_dir<'a>(
}
Ok(())
}
+
+fn is_terminal(flags: &Flags, b: &u8) -> bool {
+ *b == (b'\0' + b'\n' * !flags.nul as u8)
+}