[TxMt] Template Code

Allan Odgaard throw-away-1 at macromates.com
Thu Sep 28 21:19:55 UTC 2006


On 28/9/2006, at 23:17, Ketan Anjaria wrote:

> This is my template command
> if test \! -e "$TM_NEW_FILE"; then
>    TM_YEAR=`date +%Y` \
>    TM_DATE=`date +%Y-%m-%d` \
>    TM_USERNAME=`niutil -readprop / /users/\$USER realname` \
>    TM_PACKAGE=`sed <<<"$TM_NEW_FILE_DIRECTORY" 's#.*classes/
> ##'|tr / .`
>    perl -pe 's/\$\{([^}]*)\}/$ENV{$1}/g' \
>       < class.as > "$TM_NEW_FILE"
> fi
>
> And TM_PACKAGE comes out blank.
>
> what am I doing wrong?

You need to put a \ last on the line with sed. This makes all the  
variable settings appear on the same line as perl, so perl inherits  
these variables.

The alternative is to prefix each variable setting with ‘export’ so  
that the variable gets exported to subprocesses.






More information about the textmate mailing list