Improve precedence of command line arguments

This commit is contained in:
Richard Frith-Macdonald 2023-04-06 16:52:40 +01:00
parent 372de1721e
commit e196b76373
2 changed files with 23 additions and 16 deletions

12
ECCL.h
View file

@ -107,12 +107,10 @@
number of seconds to wait for a Want/Fail pattern to be matched. number of seconds to wait for a Want/Fail pattern to be matched.
If this timeout occurs, the process exit status is 2.<br /> If this timeout occurs, the process exit status is 2.<br />
Want (or the ConsoleWant environment variable) specifies the Want (or the ConsoleWant environment variable) specifies the
regular expression to match a single line success message to the regular expression to match a single message to the Console process.
Console process. If this response is matched the process exit If this response is matched the process exit status is 0.<br />
status is 0.<br />
Fail (or the ConsoleFail environment variable) specifies the regular Fail (or the ConsoleFail environment variable) specifies the regular
expression to match a single line failure message to the Console expression to match a single message to the Console process.
process.
If this response is matched, the process exit status is 3.<br /> If this response is matched, the process exit status is 3.<br />
While waiting for a pattern to be matched, any messages received While waiting for a pattern to be matched, any messages received
by the Console process are provided as output (to STDOUT).<br /> by the Console process are provided as output (to STDOUT).<br />
@ -122,7 +120,9 @@
If the Control server cannot be contacted, the process exit status If the Control server cannot be contacted, the process exit status
is 10.<br /> is 10.<br />
If the Control server actively refuses the login, the exit status If the Control server actively refuses the login, the exit status
is 11. is 11.<br />
NB. Command line arguments take precedence over environment variables
even if the command line aregument is an empty string.
</section> </section>
<section> <section>

View file

@ -863,8 +863,7 @@ static NSString *originalUserName = nil;
} }
} }
s = [defs stringForKey: @"Line"]; if (nil == (s = [defs stringForKey: @"Line"]))
if (0 == [s length])
{ {
s = [env objectForKey: @"ConsoleLine"]; s = [env objectForKey: @"ConsoleLine"];
} }
@ -874,9 +873,10 @@ static NSString *originalUserName = nil;
/* Now, we may delay for 'Wait' seconds looking for a response /* Now, we may delay for 'Wait' seconds looking for a response
* containing the 'Want' pattern or the 'Fail' pattern. * 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 (nil == (s = [defs stringForKey: @"Want"]))
if (0 == [s length])
{ {
s = [env objectForKey: @"ConsoleWant"]; s = [env objectForKey: @"ConsoleWant"];
} }
@ -886,8 +886,7 @@ static NSString *originalUserName = nil;
options: 0 options: 0
error: 0]; error: 0];
} }
s = [defs stringForKey: @"Fail"]; if (nil == (s = [defs stringForKey: @"Fail"]))
if (0 == [s length])
{ {
s = [env objectForKey: @"ConsoleFail"]; s = [env objectForKey: @"ConsoleFail"];
} }
@ -901,8 +900,7 @@ static NSString *originalUserName = nil;
{ {
NSTimeInterval ti; NSTimeInterval ti;
s = [defs stringForKey: @"Wait"]; if (nil == (s = [defs stringForKey: @"Wait"]))
if (0 == [s length])
{ {
s = [env objectForKey: @"ConsoleWait"]; s = [env objectForKey: @"ConsoleWait"];
if (0 == [s length]) if (0 == [s length])
@ -915,8 +913,17 @@ static NSString *originalUserName = nil;
target: self selector: @selector(waitEnded:) target: self selector: @selector(waitEnded:)
userInfo: nil repeats: NO]; userInfo: nil repeats: NO];
if (YES == [defs boolForKey: @"Quiet"] if ([defs objectForKey: @"Quiet"])
|| YES == [[env objectForKey: @"ConsoleQuiet"] boolValue]) {
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 /* If we don't want any output, return without
* setting the output channel up. * setting the output channel up.