gitmergeapplescriptaraxis

POSIX file "." as alias causes "CFURLGetFSRef was passed this URL which has no scheme" warning


I am using applescripts supplied by Araxis so that I can use Merge to handle my 'git diff HEAD` command.

However, ever since upgrading to Mountain Lion, each time I run the command, I receive the warning:

CFURLGetFSRef was passed this URL which has no scheme 
(the URL may not work with other CFURL routines): .

In the script, what seems to be causing the problem is

set _file2 to (POSIX path of (POSIX file "." as alias)) & _file2

When I hard-code the path instead of using ".", the warning goes away. I've tried pre-pending file:///, but POSIX path of is considering one of the slashes to be an escape character and so the path becomes file:/Users/... which then generates an error for being having an unknown schema (since the second slash was removed). So, my question is, what is the proper way (now, in Mountain Lion), to fetch the POSIX file for the current location?

adding full script

#!/usr/bin/osascript
# This script is required to reorder the parameters sent by Git, so that they may be passed into the Merge Applescript API
on run args
  tell application "Araxis Merge"
    set _file1 to item 2 of args as text
    set _file2 to item 5 of args as text  

    if not _file1 starts with "/"
      set _file1 to (POSIX path of (POSIX file "." as alias)) & _file1
    end if

    if not _file2 starts with "/"
      set _file2 to (POSIX path of (POSIX file "." as alias)) & _file2
    end if


    set _document to compare {_file1, _file2}

    tell _document
      activate
    end tell
    repeat while exists _document
      delay 1
    end repeat
  end tell
end run

working solution (thanks @adayzdone)

#!/usr/bin/osascript
# This script is required to reorder the parameters sent by Git, so that they may be passed into the Merge Applescript API
on run args
  tell application "Araxis Merge"
    set _file1 to item 2 of args as text
    set _file2 to item 5 of args as text  

    if not _file1 starts with "/"
      set _file1 to (POSIX path of (POSIX file (do shell script "pwd") as alias)) & _file1
    end if

    if not _file2 starts with "/"
      set _file2 to (POSIX path of (POSIX file (do shell script "pwd") as alias)) & _file2
    end if

    set _document to compare {_file1, _file2}

    tell _document
      activate
    end tell
    repeat while exists _document
      delay 1
    end repeat
  end tell
end run

Solution

  • What I need is the path to the current directory of the shell where the command is being run

    Does this work for you?

    set xxx to do shell script "pwd"