Forum: Cfengine Help
Subject: Stopping Scalar Expansion
Author: Authority
Link to topic: https://cfengine.com/forum/read.php?3,17073,17073#msg-17073

Is there a way to make Cfengine 3 treat a variable as a truly literally string 
and not attempt variable expansion?

I like to write in BASH and frequently make use of the bash style of capturing 
external program output, i.e. $(date).  This just so happens to be the same 
style Cfengine uses for variables.  Sometimes this is nice because I can write 
bash functions to mimic Cfengine's variable expansion and copy and paste 
strings from my promises and get the same result in bash, but I just ran into a 
problem trying to go the opposite way.

I was trying to pass a line of bash including an external call as a parameter 
to a bundle.  After figuring out I needed to replace my dollar signs with 
$(const.dollar) so I had things like $(const.dollar)(date), I realized that 
Cfengine was trying to expand variables when I used these strings I had passed 
as a parameter.  In the end, Cfengine still wrote the string as I wanted since 
it couldn't expand the supposed variable, but it gave me warnings for each time 
I did.

Perl and Bash both make the distinction between single and double quotes for 
whether to interpolate or not, but Cfengine appears to treat both the same.  
Does Cfengine have a function or other means of stopping variable expansion?

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to