diff --git a/src/fop.rs b/src/fop.rs index ba99ae4..09cac94 100644 --- a/src/fop.rs +++ b/src/fop.rs @@ -101,7 +101,11 @@ fn main() { 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!( "{}: {}: Command output is invalid UTF-8.", argv[0], @@ -110,7 +114,7 @@ fn main() { exit(EX_IOERR); }); - fields[index] = &new_field.trim_end(); + fields[index] = &new_field; print!("{}", fields.join(&d.to_string())); }