From 131a4e22e2fb3afa8ec0a8a35945d9511e41a4f9 Mon Sep 17 00:00:00 2001 From: Adam Carpenter <53hornet@gmail.com> Date: Thu, 28 Feb 2019 09:12:04 -0500 Subject: Removed build files from repo. --- minigrep/src/lib.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'minigrep/src') diff --git a/minigrep/src/lib.rs b/minigrep/src/lib.rs index 9f0adbd..bf7118f 100644 --- a/minigrep/src/lib.rs +++ b/minigrep/src/lib.rs @@ -20,13 +20,17 @@ impl Config { let filename = args[2].clone(); let mut case_sensitive = env::var("CASE_INSENSITIVE").is_err(); - if args.nth(3) == "-i" { - case_sensitive = false; - } - else if args[3] == "-s" { - case_sensitive = true; + // override environment variable if cli arg is present + if args.len() > 3 { + if args[3] == "-s" { + case_sensitive = true; + } + else if args[3] == "-i" { + case_sensitive = false; + } } + Ok(Config { query, filename, case_sensitive }) } -- cgit v1.2.3