Compare commits
2 Commits
6c2b7b68fd
...
6bbccb3776
Author | SHA1 | Date | |
---|---|---|---|
6bbccb3776 | |||
fd13a7f189 |
15
src/fop.rs
15
src/fop.rs
@ -33,7 +33,7 @@ use sysexits::{ EX_DATAERR, EX_IOERR, EX_UNAVAILABLE, EX_USAGE };
|
|||||||
fn main() {
|
fn main() {
|
||||||
let argv = args().collect::<Vec<String>>();
|
let argv = args().collect::<Vec<String>>();
|
||||||
let mut d = '\u{1E}'.to_string(); /* ASCII record separator */
|
let mut d = '\u{1E}'.to_string(); /* ASCII record separator */
|
||||||
let mut optind = 0;
|
let mut optind = 1;
|
||||||
|
|
||||||
let usage = format!(
|
let usage = format!(
|
||||||
"Usage: {} [-d delimiter] index command [args...]",
|
"Usage: {} [-d delimiter] index command [args...]",
|
||||||
@ -54,6 +54,12 @@ fn main() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* parse the specified index as a number we can use */
|
||||||
|
let index = argv[optind].parse::<usize>().unwrap_or_else(|e| {
|
||||||
|
eprintln!("{}: {}: {}", argv[0], argv[1], e);
|
||||||
|
exit(EX_DATAERR);
|
||||||
|
});
|
||||||
|
|
||||||
/* index of the argv[0] for the operator command */
|
/* index of the argv[0] for the operator command */
|
||||||
let command_arg = optind as usize + 1;
|
let command_arg = optind as usize + 1;
|
||||||
|
|
||||||
@ -63,12 +69,7 @@ fn main() {
|
|||||||
exit(EX_USAGE);
|
exit(EX_USAGE);
|
||||||
});
|
});
|
||||||
|
|
||||||
/* parse the specified index as a number we can use */
|
/* read entire standard input into memory */
|
||||||
let index = argv[optind].parse::<usize>().unwrap_or_else(|e| {
|
|
||||||
eprintln!("{}: {}: {}", argv[0], argv[1], e);
|
|
||||||
exit(EX_DATAERR);
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
if let Err(e) = stdin().read_to_string(&mut buf) {
|
if let Err(e) = stdin().read_to_string(&mut buf) {
|
||||||
eprintln!("{}: {}", argv[0], e.strerror());
|
eprintln!("{}: {}", argv[0], e.strerror());
|
||||||
|
@ -24,12 +24,11 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern crate getopt;
|
extern crate getopt;
|
||||||
use getopt::GetOpt;
|
|
||||||
|
|
||||||
extern crate sysexits;
|
extern crate sysexits;
|
||||||
use sysexits::{ EX_IOERR, EX_OK, EX_USAGE };
|
|
||||||
|
|
||||||
extern crate strerror;
|
extern crate strerror;
|
||||||
|
|
||||||
|
use getopt::GetOpt;
|
||||||
|
use sysexits::{ EX_IOERR, EX_OK, EX_USAGE };
|
||||||
use strerror::StrError;
|
use strerror::StrError;
|
||||||
|
|
||||||
fn err(s: &str, e: Error) { eprintln!("{}: {}", s, e.strerror()); }
|
fn err(s: &str, e: Error) { eprintln!("{}: {}", s, e.strerror()); }
|
||||||
|
Loading…
Reference in New Issue
Block a user