fixed an erroneous check to make sure a file operand is present because it isn't required
This commit is contained in:
parent
65ca86a60c
commit
1f89acec63
1 changed files with 5 additions and 4 deletions
|
@ -16,7 +16,8 @@ fn main() {
|
||||||
// Parse arguments and handle them.
|
// Parse arguments and handle them.
|
||||||
let args: Vec<String> = args().collect();
|
let args: Vec<String> = args().collect();
|
||||||
|
|
||||||
let mut error: Option<String> = Some("open: missing file operand.".to_string());
|
let mut error: Option<String> = None;
|
||||||
|
let mut file_operand = false;
|
||||||
for arg in &args[1..] {
|
for arg in &args[1..] {
|
||||||
match arg.as_str() {
|
match arg.as_str() {
|
||||||
"-h" |
|
"-h" |
|
||||||
|
@ -34,10 +35,10 @@ FLAGS:
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
if error.is_none() {
|
if file_operand {
|
||||||
error = Some("open: too many arguments.".to_string());
|
error = Some("open: too many file operands.".to_string());
|
||||||
} else {
|
} else {
|
||||||
error = None;
|
file_operand = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue