To prevent literal "$y"s or "${y}"s in the value of VARA ($x) from
expanding, you must replace the second expansion command with a
multisubstitute, and give the variable that was declared before
multisubsitete another name using define

 I would argue the opposite, i.e. that parallel substitution
(using multisubstitute) should be the norm, and that serial substitution
should only happen when you know you need the result of an early
substitutions in a later one.

 Which means I would rewrite your example as:

   multisubstitute
   {
     importas -i x VARA
     importas -i y VARB
   }
   cmdA argA $x
   cmdB argB $x $y

and there would be no problem with literal $y being replaced in the
expansion of $x. This is valid with elglob too.

 Your example with backtick doesn't work because backtick is not a
substitution command, but let's assume you wanted "importas foo BAR"
instead; and your use of "cmdA argA $cfiles" followed by the rest
of the script is sketchy, because if cmdA takes a variable number of
arguments, it would also take the whole rest of the script, so let's
put it in a foreground block.

 So you would have something like:

   multisubstitute
   {
     elglob cfiles *.c
     importas -i foo BAR
   }
   foreground { cmdA argA $cfiles }
   cmbB argB $foo $cfiles

and there will be no problem in the expansion of $foo either.

 Does that solve your issue?

--
 Laurent

Reply via email to