-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Thanks Allan, I'm going to flag this message to refer to again and again. Especially the stdin <<< which i keep forgetting about.
Please feel free to keep the tips coming ;)
Robert
On Apr 12, 2005, at 7:00 AM, Allan Odgaard 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