forked from bonsai/harakit
fop(1): better newline removal (preserves existing newlines)
This commit is contained in:
parent
4c663bf9dd
commit
448211bbe2
@ -101,7 +101,11 @@ fn main() {
|
|||||||
exit(EX_IOERR);
|
exit(EX_IOERR);
|
||||||
});
|
});
|
||||||
|
|
||||||
let new_field = String::from_utf8(output.stdout).unwrap_or_else(|_| {
|
let mut replace = output.stdout.clone();
|
||||||
|
|
||||||
|
if replace.pop() != Some(b'\n') { replace = output.stdout; }
|
||||||
|
|
||||||
|
let new_field = String::from_utf8(replace).unwrap_or_else(|_| {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"{}: {}: Command output is invalid UTF-8.",
|
"{}: {}: Command output is invalid UTF-8.",
|
||||||
argv[0],
|
argv[0],
|
||||||
@ -110,7 +114,7 @@ fn main() {
|
|||||||
exit(EX_IOERR);
|
exit(EX_IOERR);
|
||||||
});
|
});
|
||||||
|
|
||||||
fields[index] = &new_field.trim_end();
|
fields[index] = &new_field;
|
||||||
|
|
||||||
print!("{}", fields.join(&d.to_string()));
|
print!("{}", fields.join(&d.to_string()));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user