<html>#2333: piraha expands variables inside of strings
<table style='border-spacing: 1ex 0pt; '>
<tr><td style='text-align:right'> Reporter:</td><td>Roland Haas</td></tr>
<tr><td style='text-align:right'>   Status:</td><td>new</td></tr>
<tr><td style='text-align:right'>Milestone:</td><td></td></tr>
<tr><td style='text-align:right'>  Version:</td><td></td></tr>
<tr><td style='text-align:right'>     Type:</td><td>bug</td></tr>
<tr><td style='text-align:right'> Priority:</td><td>minor</td></tr>
<tr><td style='text-align:right'>Component:</td><td>Cactus</td></tr>
</table>

<p>Comment (by Roland Haas):</p>
<p>It is not documented either way, the docs just say “Parameter values can also contain variables of the form ${VARIABLE} or $ENV{VARIABLE}.”. </p>
<p>The arguments to expand or not expand would be based on what the previous parser did (it supported <code>$parfile</code>, <code>${parfile}</code> and <code>$ENV{'FOO'}</code>, what common languages in Cactus (Perl, bash, C, Fortran) would do, and what does not restrict users unnecessarily.</p>
<p>The previous parser (in <code>ParseFile.c</code> once one sets <code>piraha_active</code> to 0) handles things inconsistently:</p>
<div class="codehilite"><pre><span></span>Cactus::terminate = &quot;$parfile&quot;
</pre></div>


<p>passes the literal <code>$parfile</code> to the <code>terminate</code> option, while both</p>
<div class="codehilite"><pre><span></span>Cactus::terminate = &quot;<span class="cp">${</span><span class="n">parfile</span><span class="cp">}</span>&quot;
</pre></div>


<p>and</p>
<div class="codehilite"><pre><span></span>Cactus::terminate = $parfile
</pre></div>


<p>pass the actual name of the parfile. <code>$ENV{'FOO'}</code> was always expanded even in strings.</p>
<p>Perl and bash of course expand “$foo” in double quoted strings (but no in single quoted ones), while C and Fortran have no such functionality.</p>
<p>Piraha’s and the previous parser’s handling of <code>$ENV</code> is unfortunately inconsistent in that the previous parser required the ENV variable name to be enclosed in single quotes in the curly braces while piraha does not allow this.</p>
<p>Not expanding $ inside of strings lets people use $ in strings but requires the used of constructs like “BAR”+$FOO+”BAZ” to use variables in strings.</p>
<p>Overall since ENV variables (in their previous incarnations or piraha’s) were always expanded even inside of strings it is likely best to keep the current behaviour, ie expanding variables, even at the cost of not being able to use $ in strings directly. $ can show up in strings by using “+” eg:</p>
<div class="codehilite"><pre><span></spa
<p>--<br/>
Ticket URL: <a href='https://bitbucket.org/einsteintoolkit/tickets/issues/2333/piraha-expands-variables-inside-of-strings'>https://bitbucket.org/einsteintoolkit/tickets/issues/2333/piraha-expands-variables-inside-of-strings</a></p>
</html>