[OS X TeX] Re: Alpha, DoScript and non unix like paths

Jon Guyer jguyer at his.com
Thu Jan 6 10:08:56 EST 2005

On Jan 6, 2005, at 8:21 AM, Claus Gerhardt wrote:

> The 'quoted form of' is indeed an Applescript standard conversion. In 
> case of the DoScript command one should always use the following 
> syntax
> set fileNamedoublequoted to "\"" & fileName & "\""
> tell application "AlphaX"
> 	set theAnswer to DoScript "win::getInfo " & fileNamedoublequoted & " 
> " & "dirty"
> end tell
> This will work for any path, regardless if it complies with the unix 
> convention or not.

Actually, it won't. If the fileName has ", $, [, ] in it, you're going 
to have varying degrees of problems from Alpha, ranging from syntax 
errors to executing erroneous or even malicious code, depending on the 
name of the file.

set fileNameCurlied to "{" & fileName & "}"

would be somewhat safer, although then you have to worry about if 
you've got { or } in fileName. In the end, Tcl's quoting rules are 
fundamentally different from AppleScript's, which are fundamentally 
different from the shell's, which are fundamentally different from 
Python's, which are fundamentally different...

I think your only solutions are to either come up with the AppleScript 
equivalent of Alpha's

proc quote::Insert str {
     regsub -all {[][\\$"\{\}]} $str {\\&} str
     string map [list "\r" "\\r" "\n" "\\n" "\t" "\\t"] $str

or for us to give you a proper AppleScript interface.

The first choice assumes that AppleScript has access to the same string 
mangling facilities that Alpha does, which, short of a regular 
expression OSAX (which do exist, I know), I don't think it does. 
Languages like Tcl and Perl are fundamentally better at string handling 
than AppleScript is.

The second choice involves some things that Alpha already has [*], and 
some careful thought about what the crucial set and syntax of 
AppleScript commands should be. Alpha has thousands of Tcl commands, 
and there's no point in trying to replicate them all for 
AppleScripters, but I think we're going to be better off providing a 
proper AppleScript interface to at least basic information about 
windows, window state, as well as providing mechanisms for selecting 
and replacing text. I've already shown you how we can do some of this.

Last night, I started to write an accessor for window properties ("get 
dirty state of frontmost window" and such), but ran into a limitation 
in my ascr/gdte handler that wasn't trivial to fix. It can and will be 
fixed, but it was going to take more time than I had at the moment.

I'm curious, though. A number of the commands that you've requested 
have involved the topmost window. What happens when the topmost window 
isn't a TeX file, or isn't even associated with a file? In your ideal 
world, what would you really like to know from Alpha? Let's design a 
good interface now and save ourselves trouble in the long run.

[*] I've spent a great deal of time thinking about AppleScripting 
Alpha, actually, and have built a great deal of AppleScripting power 
into Alpha (also available to any other Tcl application), but nobody's 
ever expressed any interest in it, so I've found other things to occupy 
my time.

--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
           & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>

More information about the MacOSX-TeX mailing list