Page 1 of 1

Allow interpolation inside quote block

Posted: 08 Aug 2016 21:04
by rhaguiuda
How can I allow a variable interpolation inside a quote block?

In this script:

$a = get("curitem","path");run 'd:\ConEmuPack\ConEmu64.exe /dir $a';

I need that variable $a gets interpolated even inside the quotes of the run command.

Re: Allow interpolation inside quote block

Posted: 08 Aug 2016 21:18
by highend
Variables aren't resolved in single quotes

Code: Select all

$a = get("curitem","path"); run """d:\ConEmuPack\ConEmu64.exe"" /dir ""$a""";
This version will put $a in quotes as well (so that it works for folders with spaces in it)

And if you don't really need:
Note: get(curitem) differs from the native variable <curitem> in that it will return the previously selected and focused item if the currently focused item is not selected.
this would be enough:

Code: Select all

run """d:\ConEmuPack\ConEmu64.exe"" /dir ""<curpath>""";

Re: Allow interpolation inside quote block

Posted: 08 Aug 2016 21:32
by rhaguiuda
Thanks highend.

Is there a trick to understand this neverending number of double-quotes? They are very confusing!

Re: Allow interpolation inside quote block

Posted: 08 Aug 2016 21:40
by highend
For each pair of two double quotes the outer one is stripped.
1. run """d:\ConEmuPack\ConEmu64.exe"" /dir ""$a"""
2. run ""d:\ConEmuPack\ConEmu64.exe"" /dir ""$a""
3. run "d:\ConEmuPack\ConEmu64.exe" /dir "$a"

Always a good method to understand double quotes:
Use
step;
in a script before such a line

The stepping window will show you how XY interprets all these double / tripple quotes

Re: Allow interpolation inside quote block

Posted: 10 Aug 2016 13:12
by admin
As an alternative you can use the quote() function:

Code: Select all

run quote("d:\ConEmuPack\ConEmu64.exe") . " /dir " . quote(<curpath>);