From 1f89acec6316918983dddb480a5d9655ac640f34 Mon Sep 17 00:00:00 2001 From: Valerie Date: Fri, 18 Jun 2021 00:28:44 -0400 Subject: [PATCH] fixed an erroneous check to make sure a file operand is present because it isn't required --- src/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0eac478..4d12c30 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,8 @@ fn main() { // Parse arguments and handle them. let args: Vec = args().collect(); - let mut error: Option = Some("open: missing file operand.".to_string()); + let mut error: Option = None; + let mut file_operand = false; for arg in &args[1..] { match arg.as_str() { "-h" | @@ -34,10 +35,10 @@ FLAGS: return; }, _ => { - if error.is_none() { - error = Some("open: too many arguments.".to_string()); + if file_operand { + error = Some("open: too many file operands.".to_string()); } else { - error = None; + file_operand = true; } } }