Mailing List Archives
Public Access
|
|
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [HTCondor-users] Complex conditionals in Configuration
- Date: Wed, 8 Jun 2022 19:29:42 +0000
- From: John M Knoeller <johnkn@xxxxxxxxxxx>
- Subject: Re: [HTCondor-users] Complex conditionals in Configuration
The explanation for this is that $() expansions don't actually have a data type, they are all just text. Some of them do evaluation, and expect that after evaluation, the result will have a specific type.
In your particular example $ENV(var) will not *add* quotes if var does not already have them. $ENV() does not expect data of any specific type.
To give some examples
--- config fragment ---
EX1 = 1
EX2 = 2
EX3 = 1+2
TEMP = $INT(EX1), $INT(EX2), $INT(EX3)
> condor_config_val TEMP
1, 2, 3
TEMP is 1,2,3 because $INT() will look up EX1 and then evaluate that as and expression and print the result as an integer, then lookup EX2, and evaluate that, and so on. The evaluation is a consequence of the way $INT() works.
Contrast that with $ENV(), which does NOT evaluate what it looks up.
export EX1=1
export EX2=2
export EX3=1+2
--- config fragment ---
TEMP = $ENV(EX1), $ENV(EX2), $ENV(EX3)
> condor_config_val TEMP
1, 2, 1+2
The manual will say whether a $ expansion function will do evaluation after lookup. Some of the functions do, some do not. $INT(), and $STRING() exist specifically to do evaluation and to format the result in a specific way.
For instance,
EX3 = 10+2
TEMP = $INT(EX3), $INT(EX2,%02x)
> condor_config_val TEMP
12, 0c
-tj
-----Original Message-----
From: HTCondor-users <htcondor-users-bounces@xxxxxxxxxxx> On Behalf Of Stanislav V. Markevich via HTCondor-users
Sent: Tuesday, June 7, 2022 4:10 PM
To: htcondor-users <htcondor-users@xxxxxxxxxxx>
Cc: Stanislav V. Markevich <stanislav.markevich@xxxxxxxxxxxxxx>
Subject: Re: [HTCondor-users] Complex conditionals in Configuration
Hi John,
thank you for your reply, it works fine than MY_CONDITION is a string literal. It surprised me that if I want to get the value of MY_OPTION from an environment variable I have to wrap it in quotes:
MY_OPTION = "$ENV(MY_OPTION_IN_ENV)"
without quotes I get the following:
ERROR "$INT() macro: one == "one" does not evaluate to an integer!" at line 3463 in file /htcondor/src/condor_utils/config.cpp
I expected that $ENV evaluates to a string.
Best regards,
Stanislav Markevich
----- Original Message -----
From: "John M Knoeller" <johnkn@xxxxxxxxxxx>
To: "htcondor-users" <htcondor-users@xxxxxxxxxxx>
Sent: Monday, 6 June, 2022 16:38:07
Subject: Re: [HTCondor-users] Complex conditionals in Configuration
You need to use a temporary variable to hold the condition, and then use $EVAL or $INT when you reference it, like this.
MY_CONDITION = $(MY_OPTION) == "one"
if $INT(MY_CONDITION)
The limitation here is that the $() expansion parser doesn't allow a $ inside the body of a $() or $func() macro reference, so you need to set things up so that is avoided. To assist in this $INT(), $STRING() and $EVAL() expect their argument to be a variable that contains an expression, not the expression itself.
-tj
-----Original Message-----
From: HTCondor-users <htcondor-users-bounces@xxxxxxxxxxx> On Behalf Of Stanislav V. Markevich via HTCondor-users
Sent: Sunday, June 5, 2022 4:10 PM
To: htcondor-users@xxxxxxxxxxx
Cc: Stanislav V. Markevich <stanislav.markevich@xxxxxxxxxxxxxx>
Subject: [HTCondor-users] Complex conditionals in Configuration
Hello all,
I'm trying to check value of some macro in a condition and cannot understand how should I do it.
If the macro evaluates to a simple boolean value (true, false, 0, 1, etc) there is no problem. But what if I want to compare with other values?
For example, I want to check if $(MY_OPTION) evaluates to the value "one". I cannot just write
if $(MY_OPTION) == "one"
...
because of complex conditionals are not supported. So I have somehow evaluate this expression and put the result into some other macro, but how can I do it?
I tried
MY_CONDITION = $EVAL( $(MY_OPTION) == "one")
if $(MY_CONDITION)
...
and some other options but still get the same error "$(MY_CONDITION) is not a valid if condition because complex conditionals are not supported".
Any help would be greatly appreciated.
Best regards,
Stanislav V. Markevich
_______________________________________________
HTCondor-users mailing list
To unsubscribe, send a message to htcondor-users-request@xxxxxxxxxxx with a
subject: Unsubscribe
You can also unsubscribe by visiting
https://lists.cs.wisc.edu/mailman/listinfo/htcondor-users
The archives can be found at:
https://lists.cs.wisc.edu/archive/htcondor-users/
_______________________________________________
HTCondor-users mailing list
To unsubscribe, send a message to htcondor-users-request@xxxxxxxxxxx with a
subject: Unsubscribe
You can also unsubscribe by visiting
https://lists.cs.wisc.edu/mailman/listinfo/htcondor-users
The archives can be found at:
https://lists.cs.wisc.edu/archive/htcondor-users/
_______________________________________________
HTCondor-users mailing list
To unsubscribe, send a message to htcondor-users-request@xxxxxxxxxxx with a
subject: Unsubscribe
You can also unsubscribe by visiting
https://lists.cs.wisc.edu/mailman/listinfo/htcondor-users
The archives can be found at:
https://lists.cs.wisc.edu/archive/htcondor-users/