aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-08-12 13:43:47 +0200
committerThomas Voss <mail@thomasvoss.com> 2023-08-12 13:43:47 +0200
commitcc65dda056a146541c2894604448a4512deed3c4 (patch)
treeb20712caf726dc586d4cba62c6acbbab531ddb14
parentb9e722a2f6f61f92db26d02c083f1f1bb242003f (diff)
When using -e, swap back to newlines from nul
-rw-r--r--src/main.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 2681a55..af958b0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -92,7 +92,7 @@ fn work() -> Result<(), io::Error> {
let srcs = io::stdin()
.bytes()
.map(|x| require!(x))
- .group_by(|b| is_terminal(&flags, b));
+ .group_by(|b| is_terminal(flags.nul, b));
let srcs = srcs
.into_iter()
.filter(|(x, _)| !x)
@@ -316,7 +316,7 @@ fn run_multi(
src.to_owned()
}
)?;
- ci.write_all(if flags.nul { &[b'\0'] } else { &[b'\n'] })?;
+ ci.write_all(if flags.nul && !flags.encode { &[b'\0'] } else { &[b'\n'] })?;
}
}
@@ -327,7 +327,7 @@ fn run_multi(
let groups = co
.bytes()
.map(|x| require!(x))
- .group_by(|b| is_terminal(flags, b));
+ .group_by(|b| is_terminal(flags.nul && !flags.encode, b));
groups
.into_iter()
.filter_map(|(x, y)| match x {
@@ -455,8 +455,8 @@ 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)
+fn is_terminal(nul: bool, b: &u8) -> bool {
+ *b == (b'\0' + b'\n' * !nul as u8)
}
fn disp(pb: &PathBuf) -> Display {