diff --git a/ECCL.h b/ECCL.h index 14ef666..cdc925c 100644 --- a/ECCL.h +++ b/ECCL.h @@ -107,12 +107,10 @@ number of seconds to wait for a Want/Fail pattern to be matched. If this timeout occurs, the process exit status is 2.
Want (or the ConsoleWant environment variable) specifies the - regular expression to match a single line success message to the - Console process. If this response is matched the process exit - status is 0.
+ regular expression to match a single message to the Console process. + If this response is matched the process exit status is 0.
Fail (or the ConsoleFail environment variable) specifies the regular - expression to match a single line failure message to the Console - process. + expression to match a single message to the Console process. If this response is matched, the process exit status is 3.
While waiting for a pattern to be matched, any messages received by the Console process are provided as output (to STDOUT).
@@ -122,7 +120,9 @@ If the Control server cannot be contacted, the process exit status is 10.
If the Control server actively refuses the login, the exit status - is 11. + is 11.
+ NB. Command line arguments take precedence over environment variables + even if the command line aregument is an empty string.
diff --git a/EcConsole.m b/EcConsole.m index 053c1cf..9319e78 100644 --- a/EcConsole.m +++ b/EcConsole.m @@ -863,8 +863,7 @@ static NSString *originalUserName = nil; } } - s = [defs stringForKey: @"Line"]; - if (0 == [s length]) + if (nil == (s = [defs stringForKey: @"Line"])) { s = [env objectForKey: @"ConsoleLine"]; } @@ -874,9 +873,10 @@ static NSString *originalUserName = nil; /* Now, we may delay for 'Wait' seconds looking for a response * containing the 'Want' pattern or the 'Fail' pattern. + * An empty string as a command line argument turns off + * pattern matching specified in the environment. */ - s = [defs stringForKey: @"Want"]; - if (0 == [s length]) + if (nil == (s = [defs stringForKey: @"Want"])) { s = [env objectForKey: @"ConsoleWant"]; } @@ -886,8 +886,7 @@ static NSString *originalUserName = nil; options: 0 error: 0]; } - s = [defs stringForKey: @"Fail"]; - if (0 == [s length]) + if (nil == (s = [defs stringForKey: @"Fail"])) { s = [env objectForKey: @"ConsoleFail"]; } @@ -901,8 +900,7 @@ static NSString *originalUserName = nil; { NSTimeInterval ti; - s = [defs stringForKey: @"Wait"]; - if (0 == [s length]) + if (nil == (s = [defs stringForKey: @"Wait"])) { s = [env objectForKey: @"ConsoleWait"]; if (0 == [s length]) @@ -915,8 +913,17 @@ static NSString *originalUserName = nil; target: self selector: @selector(waitEnded:) userInfo: nil repeats: NO]; - if (YES == [defs boolForKey: @"Quiet"] - || YES == [[env objectForKey: @"ConsoleQuiet"] boolValue]) + if ([defs objectForKey: @"Quiet"]) + { + if ([defs boolForKey: @"Quiet"]) + { + /* If we don't want any output, return without + * setting the output channel up. + */ + return self; + } + } + else if ([[env objectForKey: @"ConsoleQuiet"] boolValue]) { /* If we don't want any output, return without * setting the output channel up.