On 28 Jan 2008, at 10:31, Ian Wood wrote:

function ijwAPLIB_MakeOSXShellPath tPath
put "set tOut to quoted form of POSIX path of tPath" into tScript
replace "tPath" with quote & revMacFromUnixPath(tPath) & quote in tScript
do tScript as applescript
put the result into tNewPath
delete char 1 of tNewPath
delete last char of tNewPath
return tNewPath
end ijwAPLIB_MakeOSXShellPath

Oops. Just discovered that the above function doesn't cope with file paths that contain any kind of quote mark.

The following function should work better, escaping characters rather than putting quote marks around the whole path.

Can anyone think of other problems that might crop up when converting Rev paths to escaped paths for use in OS X shell scripts? I think I've got all the command characters that can actually be used in legal file names.

function ijwAPLIB_MakeOSXShellPath tPath
put "set tOut to POSIX path of tPath" into tScript
replace "tPath" with quote & revMacFromUnixPath(tPath) & quote in tScript
do tScript as applescript
put the result into tNewPath
delete char 1 of tNewPath
delete last char of tNewPath
replace space with "\" & space in tNewPath
replace quote with "\" & quote in tNewPath
replace "'" with "\" & "'" in tNewPath
replace "*" with "\" & "*" in tNewPath
replace "?" with "\" & "?" in tNewPath
replace "[" with "\" & "[" in tNewPath
replace "]" with "\" & "]" in tNewPath
replace "{" with "\" & "{" in tNewPath
replace "}" with "\" & "}" in tNewPath
replace "$" with "\" & "$" in tNewPath
replace "!" with "\" & "!" in tNewPath
replace "&" with "\" & "&" in tNewPath
replace "|" with "\" & "|" in tNewPath
replace ">" with "\" & ">" in tNewPath
replace "<" with "\" & "<" in tNewPath
replace ";" with "\" & ";" in tNewPath
replace "(" with "\" & "(" in tNewPath
replace "(" with "\" & ")" in tNewPath
return tNewPath
end ijwAPLIB_MakeOSXShellPath

Ian
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to