I have been using a shell of some sort for 8 years now and i had not known that you could do that. how humbling.
On Apr 12, 2005 10:00 AM, Allan Odgaard allan@macromates.com wrote:
On Apr 11, 2005, at 17:34, Alain Matthes wrote:
echo $TM_FILEPATH | perl -e 'while(<>){s/.tex$/.pdf/;print;}' | xargs
I generally avoid commenting on code unless I'm asked, but here's a few tips which I think will be useful in a lot of TM-related shell scripts, don't take it personal that this was triggered by your script! :)
The shell is capable of doing replacements in variables. There's a few different forms, for this one, one can do: ${variable%suffix_to_remove}, e.g.:
${TM_FILEPATH%.tex}.pdf
Another form is (for single replacement): ${variable/search/replace} and to replace all instances it's: ${variable//search/replace}.
Another neat thing is that we can set stdin for a command to a string using <<<, for example:
perl <<<$TM_FILEPATH -pe 's/\.tex$/.pdf/' | xargs
Kind regards Allan
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate