cat(1): better argv0 parsing
This commit is contained in:
parent
eb0ae4665f
commit
c33d9e0556
10
src/cat.rs
10
src/cat.rs
@ -29,6 +29,8 @@ use sysexits::ExitCode;
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
struct Arguments {
|
||||
argv0: String,
|
||||
|
||||
#[arg(short = "u")]
|
||||
u: bool,
|
||||
|
||||
@ -36,15 +38,15 @@ struct Arguments {
|
||||
}
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let mut arguments = env::args().collect::<Vec<String>>();
|
||||
let argv0 = arguments.remove(0);
|
||||
|
||||
let mut args = Arguments::from_args(arguments
|
||||
let mut args = Arguments::from_args(env::args()
|
||||
.collect::<Vec<String>>()
|
||||
.iter()
|
||||
.map(String::as_str)
|
||||
.collect::<Vec<&str>>()
|
||||
).unwrap();
|
||||
|
||||
let argv0 = args.argv0;
|
||||
|
||||
let mut output = String::new();
|
||||
|
||||
if args.paths.is_empty() { args.paths.push("-".to_string()); }
|
||||
|
Reference in New Issue
Block a user