[SVN] Passing variables to osascript, or other workaround?

Allan Odgaard allan at macromates.com
Wed May 11 21:55:47 UTC 2005

On May 11, 2005, at 22:58, Charilaos Skiadas wrote:

> My problem basically is: how can I pass a list of strings to 
> osascript, so that it can perceive them as a list, and so that "choose 
> from list" would work as expected. I am clearly misundestanding 
> something. The script I was trying is:

I think the problem was something with the list containing illegal 
(according to AS) characters, probably it had \ in front of the quotes 
(looking at your pattern).

I took the library to use perl instead of sed, because it has an IMHO 
much better regex grammar (and more capabilities), I also changed stdin 
for the command to be “entire document” so grep can just work on that 
instead of TM_FILEPATH, plus let awk write result to stdout directly 
rather than go through a variable:

list=`grep '\\label{.*}'|perl -pe 's/.*\\label\{(.*?)\}(.*)\n/"$1 : 
res=`osascript <<EOF
	tell application "System Events"
		choose from list { ${list:0:${#list}-1} }
	end tell
osascript -e 'tell app "TextMate" to activate' &>/dev/null &
awk <<<$res '{ printf("%s", $1) }'

Btw: questions like these should be sent to the normal user list.

More information about the textmate-dev mailing list