help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Variables: ${}


From: paguerlais
Subject: Re: Variables: ${}
Date: Fri, 20 Jan 2006 08:54:05 +0100

I use the () form for cfengine variables, to distinguish them with shell
variables. This is especially true for shellcommands.
The trick is that cfengine tries first to resolve the variable as a
cfengine variable. If it can't, it then passes the string $... to the
shellcommand, which has to resolve it. If you use () for cfengine variables
and mistype a variable name, cfagent willt not achieve and and rely on the
shell to deal with it. The shell will then fail.
Little precision : I works perfectly with bourne-shell, I don't know with
others.

Example
<cfagent>
   shellcommands:
      "/some/command $(cfengine_variable) ${shell_variable}"
</cfagent>

Patrice



                                                                       
             Jeremy Mates                                              
             <jmates@sial.org>                                         
             Envoyé par :                                                A
             help-cfengine-bou         help-cfengine@gnu.org           
             nces+paguerlais=a                                          cc
             irfrance.fr@gnu.o                                         
             rg                                                      Objet
                                       Re: Variables: ${}              
                                                                       
             20/01/2006 05:04                                          
                                                                       
                                                                       
                                                                       
                                                                       




* Atom Powers <atom.powers@gmail.com>
> What is the recommended way to express variables?
> Most of the time I use $(variable) but I've seen some cases where
> ${variable} is required.
> Are there any cases where $(variable) is required?

I always use ${variable}, as this provides visual contrast with the
Function() and ( class definition ) uses.


_______________________________________________
Help-cfengine mailing list
Help-cfengine@gnu.org
http://lists.gnu.org/mailman/listinfo/help-cfengine





reply via email to

[Prev in Thread] Current Thread [Next in Thread]