when you create an alias, the Finder makes a document and interestingly enough, a resource fork, to contain an ALIS resource. As was previously mentioned, contains a string path to the file as well as the device guid + device inode of the file or folder. Either one of these is often enough to find a file, and any app that uses the mac os APIs to resolve it will have no problem with it. Terminal commands don't support aliases, but translation IS possible. If you rename a file, OR a folder / drive in the path of the file, and then try to use the gui to access it, it will discover one mode is invalid, and will use the other good mode to fix the first one, and then access the file normally.

If you change BOTH the inode AND the path, the alias will break. You already know how to change the path, but to change the inode simply make a different file by the same name in a different folder, and drag it into the original's folder. Finder will prompt you and you can replace it. Same path, different inode. If you then rename the file, you have changed its path and its inode, and any alias to it is now broken.

Terminal uses hard and soft symbolic links instead. Soft symbolic links are just the path part of an ALIS. Hard symbolic links are duplicate directory entries for the same inode, and so they're like the inode half of the ALIS, but can't cross volumes. The OS is weird with hard links... a file isn't truly deleted until ALL of the hard links (including the original one) are removed - if any of them exist, the file still exists. You can overwrite and replace a file all day long and soft ("symbolic") links to it will continue to work. You can rename or move a file all day long (or even rm it!) and hard links to it will continue to work. So each has its own specific advantages.

This applescript (callable in terminal with osascript) uses Finder to get the unix path of a Finder alias, which you can use to make or replace it with a hard or soft link.

tell application "Finder"
set theItem to (POSIX file "'${item_path}'") as alias
if the kind of theItem is "alias" then
get the posix path of (original item of theItem as text)
end if
end tell

I've seen a way to create a finder alias from a path (the reverse of the above) but I don't see it offhand here. Maybe buried in the sands of time?

It's interesting to see that Finder icons and aliases are really the only two resource fork resource types still actively in use in mac os.

oh also, in most cases when you access an alias with Finder, (cmd-click on it, or get info etc) mac os checks to see if the target's icon has changed. if it has, it usually changes the alias's icon to match it. Otherwise alias icons don't change when their target does.


I work for the Department of Redundancy Department