Tags - what are they good for?

Hardlinking directories is a feature of HFS+. It still works.

Must be some sort of trick to do so.

tom@tom11 temp % mkdir foo
tom@tom11 temp % ln foo bar
ln: foo: Is a directory
tom@tom11 temp % 

The macOS implementation of ln doesn’t allow it. A quick search and I found the trick. You can either write a small, trivial program that executes the link system command or download one of a couple of programs that will do it. Then apparently you have to go though a similar convoluted process to remove the link. Anyway, I’ll stick with soft links!

Now the next question is why Finder creates Alias files but not soft links (or hard links but that’s another issue) yet from the command line you can create soft links but not Alias files. You can use linked files/folders in Finder but, as far as I can tell, you cannot use Alias files on the command line.

Yes, you can either write a wrapper around the system call, or you can use the Gnu version of the ln command (there’s also a set of rules that must be followed). It’s easy to understand how critical this capability was (and still is) to Time Machine using HFS+ drives (a different mechanism is used with APFS drives).

I was looking at this just the other day. Although Finder adds the little curved-arrow sub-icon to both aliases and symlinks, they are not the same. An alias is a regular file with a header that identifies it as such. I don’t know why it’s done this way.

EDIT: Apparently the advantage of an alias is that it will continue to work if it is moved, whereas a symlink will not.

By comparison, shell level operations will work only with symlinks.


JJW

I’m sure both of you understand what I’m about to point out, but for those who are, perhaps, not as versed in command line (shell) operations: You can do anything with an alias that you can do with a regular file (because that’s what it is) - move, rename, copy, delete, perhaps even edit as long as you understand that you are manipulating the alias file, not the file that the alias represents.

Aliases are Finder artifacts, links are filesystem features.

It would be interesting to try linking an alias…

It doesn’t get you far:

tom@tom11 foo % ls
Alias of original.txt	linkOfAlias.txt		original.txt
tom@tom11 foo % cat original.txt
Hello world!
tom@tom11 foo % cat Alias\ of\ original.txt 
bookmark88Lp9????s?A$Userstomfoo
                                original.txt ,Z %kdt?A?s?oƦ?    file:///
                                                                        Macintosh H??A??D?$34018DB8-0384-4478-B37B-CA5ED77EDF40???/NSURLDocumentIdentifierKey?3dnibtxt???? ????L??@?T?U?V? ?  , ` @ P  ?0 ??? ?????8"?????%                    
tom@tom11 foo % cat linkOfAlias.txt 
bookmark88Lp9????s?A$Userstomfoo
                                original.txt ,Z %kdt?A?s?oƦ?    file:///
                                                                        Macintosh H??A??D?$34018DB8-0384-4478-B37B-CA5ED77EDF40???/NSURLDocumentIdentifierKey?3dnibtxt???? ????L??@?T?U?V? ?  , ` @ P  ?0 ??? ?????8"?????%                     tom@tom11 foo % 

However, a program using macOS system calls sees these all the same. BBedit, for instance, opens all three of these (and they are all the same text file, of course).

1 Like