swab(1): don't accept positional arguments

This commit is contained in:
dtb 2024-07-08 11:45:01 -06:00
parent 35d54d84b0
commit 1fd768057c
Signed by: trinity
GPG Key ID: 34C0543BBB6AF81B

View File

@ -48,7 +48,8 @@ fn main() -> ExitCode {
let mut input = stdin(); let mut input = stdin();
let mut output = stdout().lock(); let mut output = stdout().lock();
let mut wordsize: usize = 2; let mut optind: usize = 1; // argv[0]
let mut wordsize: usize = 2; // Equivalent to dd(1p).
while let Some(opt) = argv.getopt(":w:") { while let Some(opt) = argv.getopt(":w:") {
match opt.opt() { match opt.opt() {
@ -59,11 +60,16 @@ fn main() -> ExitCode {
_ => { return usage(&argv[0]); }, _ => { return usage(&argv[0]); },
} }
} }
optind = opt.ind();
}, },
_ => { return usage(&argv[0]); } _ => { return usage(&argv[0]); }
} }
} }
if optind < argv.len() {
return usage(&argv[0]);
}
buf.resize(wordsize, 0); buf.resize(wordsize, 0);
loop { loop {