#2333: piraha expands variables inside of strings
| Reporter: | Roland Haas |
| Status: | new |
| Milestone: | |
| Version: | |
| Type: | bug |
| Priority: | minor |
| Component: | Cactus |
Comment (by Roland Haas):
It is not documented either way, the docs just say “Parameter values can also contain variables of the form ${VARIABLE} or $ENV{VARIABLE}.”.
The arguments to expand or not expand would be based on what the previous parser did (it supported $parfile, ${parfile} and $ENV{'FOO'}, what common languages in Cactus (Perl, bash, C, Fortran) would do, and what does not restrict users unnecessarily.
The previous parser (in ParseFile.c once one sets piraha_active to 0) handles things inconsistently:
Cactus::terminate = "$parfile"
passes the literal $parfile to the terminate option, while both
Cactus::terminate = "${parfile}"
and
Cactus::terminate = $parfile
pass the actual name of the parfile. $ENV{'FOO'} was always expanded even in strings.
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.
Piraha’s and the previous parser’s handling of $ENV 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.
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.
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: