5 ms·
That’s a very Linux-centric view. Neither of these works on BSD. It’s probably fine if you’re writing scripts that only need to run on Linux, but I wouldn’t cal
by robinhouston 7y ago
That’s a very Linux-centric view. Neither of these works on BSD. It’s probably fine if you’re writing scripts that only need to run on Linux, but I wouldn’t call it the “right method”.
- jsjohnst 7y agoReadlink is available on FreeBSD, OpenBSD, and NetBSD. https://www.freebsd.org/cgi/man.cgi?query=readlink&sektion=1 https://www.freebsd.org/cgi/man.cgi?query=readlink&sektion=1 So how is that a Linux-centric view again?
- robinhouston 7y agoSure, readlink exists. And it lets you read symlinks. But it can’t be used to convert relative to absolute directory paths, which I thought was the use you were proposing.
- jsjohnst 7y agoFrom the man page: > if the -f option is specified, the output is canonicalized by following every symlink in every component of the given path recursively. readlink will resolve both absolute and relative paths, and return the absolute pathname corresponding to file. In this case, the argument does not need to be a symbolic link. This is the case for *BSD, GNU/Linux, and Irix. If macOS would prioritize being consistent with the other Nix OSs, it would be supported too, but alas Apple doesn’t.