[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Expanding variables in ReturnsZero function
From: |
Mark . Burgess |
Subject: |
Re: Expanding variables in ReturnsZero function |
Date: |
Thu, 1 Aug 2002 13:44:46 +0200 (MET DST) |
Actually, variables are expanded here, but youmust used ${} not $().
IsDefined and StrCmp are added to 2.0.4
M
On 25 Jul, To: paguerlais@airfrance.fr wrote:
>
> This would not work anyway as written.
> Seems like some additional operators would be useful
>
> IsDefined(var)
> StrCmp(s1,s2)
>
> etc. Will add to next release -- once my RSI allows me to work again.
>
> M
>
> On 25 Jul, paguerlais@airfrance.fr wrote:
>>
>> Hi all,
>>
>> I want to give a variable with a default value if it's not already defined.
>> The only way I found to do that was to use a ReturnsZero function to test
>> the current value of the variable, and to initialize it it's null :
>> <cut>
>> control:
>> host1::
>> my_var = ( value_for_host1 )
>> host2::
>> my_var = ( value_for_host2 )
>>
>> groups:
>> my_var_is_already_valued = ( ReturnsZero(/bin/test -n "$(my_var)") )
>>
>> control:
>> !my_var_is_already_valued::
>> my_var = ( some_default_value )
>> </cut>
>>
>> It doesn't work because cfengine doesn't expand variables used in a command
>> for an internal function (I've spent some time reading functions.c,
>> popen.c, misc.c and varstring.c). Is this done in purpose (and the next
>> question is why), or was this feature simply forgot ? I'd like that feature
>> not only for command arguments, but also for the command itself (you define
>> a variable named TEST and valued with /bin/test, and you call ReturnsZero
>> ($(TEST) ... ))
>>
>> Next, is there a better way to test if a variable has a value ?
>>
>> Thanks
>> Patrice
>>
>>
>>
>>
>>
>> ----------------
>>
>> Les donnees et renseignements contenus dans ce message sont personnels,
>> confidentiels et secrets. Ce message est adresse a l'individu ou l'entite
>> dont les coordonnees figurent ci-dessus. Si vous n'etes pas le bon
>> destinataire, nous vous demandons de ne pas lire, copier, utiliser ou
>> divulguer cette communication. Nous vous prions de notifier cette erreur a
>> l'expediteur et d'effacer immediatement cette communication de votre systeme.
>>
>> The information contained in this message is privileged, confidential, and
>> protected from disclosure. This message is intended for the individual or
>> entity adressed herein. If you are not the intended recipient, please do not
>> read, copy, use or disclose this communication to others ;also please notify
>> the sender by replying to this message, and then delete it from your system.
>>
>>
>> _______________________________________________
>> Help-cfengine mailing list
>> Help-cfengine@gnu.org
>> http://mail.gnu.org/mailman/listinfo/help-cfengine
>
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Work: +47 22453272 Email: Mark.Burgess@iu.hio.no
> Fax : +47 22453205 WWW : http://www.iu.hio.no/~mark
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work: +47 22453272 Email: Mark.Burgess@iu.hio.no
Fax : +47 22453205 WWW : http://www.iu.hio.no/~mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Expanding variables in ReturnsZero function,
Mark . Burgess <=