Compare commits

..

No commits in common. "d2ae35eac9eca030d9b96252706da8494b7f5b18" and "09193a14d5dcdc324387081667c02aa4854bee0b" have entirely different histories.

View File

@ -71,7 +71,7 @@ fn main() {
let mut buf = String::new();
if let Err(e) = stdin().read_to_string(&mut buf) {
eprintln!("{}: {}", argv[0], e.strerror());
eprintln!("{}: {}", argv[0], e.strerror);
exit(EX_IOERR);
};
@ -79,7 +79,7 @@ fn main() {
let mut fields = buf.split(&d).collect::<Vec<&str>>();
/* collect arguments for the operator command */
let command_args = argv
let opts = argv
.iter()
.clone()
.skip(command_arg + 1) /* skip the command name */
@ -87,7 +87,7 @@ fn main() {
/* spawn the command to operate on the field */
let mut spawned = Command::new(operator)
.args(command_args) /* spawn with the specified arguments */
.args(opts) /* spawn with the specified arguments */
.stdin(Stdio::piped())
.stdout(Stdio::piped()) /* piped stdout to handle output ourselves */
.spawn()
@ -120,13 +120,8 @@ fn main() {
/* get the output with which the original field will be replaced */
let mut replace = output.stdout.clone();
/* pop trailing newline out if the input did not contain it */
if fields[index].chars().last() != Some('\n') /* no newline */
&& replace.pop() != Some(b'\n') { /* pop last char of replacement */
/* restore replacement to original command output if popped char was not
* a newline */
replace = output.stdout;
}
/* as long as its not a newline, set the replacement to the output */
if replace.pop() != Some(b'\n') { replace = output.stdout; }
/* convert the output of the program to UTF-8 */
let new_field = String::from_utf8(replace).unwrap_or_else(|e| {