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.
If this timeout occurs, the process exit status is 2.<br />
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.<br />
regular expression to match a single message to the Console process.
If this response is matched the process exit status is 0.<br />
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.<br />
While waiting for a pattern to be matched, any messages received
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
is 10.<br />
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>

View file

@ -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.