-1

I have an AppleScript Library file (.scpt) saved in ~/Library/Script Libraries which I use to call handlers from, in other scripts. I want also want to keep that file as part of a git repository. So my idea was: create a hard link in ~/Library/Script Libraries to the file in my repository.

When I first open the hard link, I see the exact same result as when opening the original file in my repo.

Checking the hard link in the Terminal renders the following result:

-rw-r--r--@ 2 username  staff  50458 May 15 16:45 MyLibrary.scpt

Pay attention to the filesize and the number of hard links (2).

When I change something in the target file, the hard link doesn't work anymore. Even when I just open the .scpt file, and save it without a change, the hard link seems broken.

When I check the hard link in the Terminal, it shows the following:

-rw-rw-rw-@ 1 username  staff  0 May 15 16:45 MyLibrary.scpt

So it is 0 bytes and the number of hard link has been reduced to 1.

Why does this not work? Does saving the original file change the inode it refers to?

smizzlov
  • 568
  • 6
  • 16
  • Same effect here. I think when a script gets saved, Script-Editor renames the original, saves the new one and the "original" gets deleted. –  May 15 '15 at 15:56

2 Answers2

1

I ended up solving the problem by changing my AppleScript build system in Sublime Text.

{
    "cmd": ["/usr/bin/osascript", "$file"],

    "variants": [
        {
            "name": "Script Library",
            "cmd": ["/usr/bin/osacompile", "-o", "/Volumes/harddisk/Users/username/Library/Script Libraries/$file_base_name.scpt", "$file"]
        }        
    ]
}

I edit the .applescript file, which is tracked in the repository. When I run the Build command, the .applescript file is compiled to its .scpt variant in the Script Libraries folder.

smizzlov
  • 568
  • 6
  • 16
0

If hard links breaks, then Script Editor like many apps and programs, writes contents to a new file. But, symbolic links should work. So, the solution is to use symbolic links. The disadvantage, is that the symbolic link, breaks if you move the file. (The symbolic link, really uses the name/path of the file, and not the inode number.) Now, if you were only linking to a local repo, then maybe you could get by by using an alias, but I doubt it will work when you push/pull to the external repo. Github, will probably never standardize on hfs disks. ;)

McUsr
  • 1,400
  • 13
  • 10
  • Having a soft link to the .scpt file in the Script Libraries folder, does not enable the script library, while having a soft link in the repository makes no sense either. So soft links are not a solution to this problem. – smizzlov May 26 '15 at 07:39