[TxMt] how to concatenate templates ?
Allan Odgaard
throw-away-2 at macromates.com
Sun Nov 11 07:54:47 UTC 2007
On 11 Nov 2007, at 03:49, Roberto Saccon wrote:
> [...]
> I tried to to turn it into somethng like this:
>
> if [[ ! -f "$TM_NEW_FILE" ]]; then
> TM_YEAR=`date +%Y` \
> TM_DATE=`date +%Y-%m-%d` \
> TM_USERNAME=`niutil -readprop / /users/\$USER realname` \
> perl -pe 's/\$\{([^}]*)\}/$ENV{$1}/g' \
> < template_in.txt << License.txt > "$TM_NEW_FILE"
> fi
Try this instead:
if [[ ! -f "$TM_NEW_FILE" ]]; then
TM_YEAR=`date +%Y` \
TM_DATE=`date +%Y-%m-%d` \
cat template_in.txt License.txt \
|perl -pe 's/\$\{([^}]*)\}/$ENV{$1}/g' > "$TM_NEW_FILE"
fi
Here we use ‘cat’ to actually con_cat_enate two files, must be a
first ;)
Note I also removed the setup of TM_USERNAME -- we now have
TM_FULLNAME as a “built-in” since relying on niutil or similar was too
fragile, but I forgot to update the template for the New Template.
More information about the textmate
mailing list