[TxMt] Mercurial bundle

Allan Odgaard throw-away-1 at macromates.com
Wed May 3 18:48:48 UTC 2006


On 3/5/2006, at 20:28, Fred B. wrote:

>    eval "$TM_HG" log -v $HG_LIMIT --style "'$HG_STYLE'"  
> $TM_SELECTED_FILES 2>&1

I’m not sure why Ollivier gets an error, would indicate that there is  
a ' in the value of HG_STYLE.

However, there are some problems with this line. First,  
$TM_SELECTED_FILES should be quoted. Second, the eval causes the line  
to be re-interpreted after initial variable expansion, this is why  
you get an error without the single quotes.

So, the two solutions which spring to mind is 1) keep the single  
quotes and escape any potential single quotes in HG_STYLE, if bash  
wasn’t broken (to the best of my knowledge) that would make it "'$ 
{HG_STYLE//'/'\''}'", or 2) use one level of indirection, like this:

    dummy='$HG_STYLE'
    eval "$TM_HG" log -v $HG_LIMIT --style "$dummy"  
"$TM_SELECTED_FILES" 2>&1

Now $dummy will expand to $HG_STYLE, and the eval will again expand  
that to the actual value.

There is a potential similar problem with TM_HG, if that variable  
contains shell special characters.




More information about the textmate mailing list