Closed ruduran closed 7 years ago
Unfortunately readlink
isn't portable. Most unixlikes have it, but the options and usage varies a lot. For example, on OSX, and presumably BSD:
~$ readlink -nf .z
readlink: illegal option -- f
usage: readlink [-n] [file ...]
I just realised we could just use cp instead of mv. Is there any reason why it cannot be used?
cp
is not atomic, so the datafile can (and will) get clobbered. That's why the whole cumbersome temp file and mv
(which is atomic) process is there in the first place :)
Understood, i'll try to find a better approach then :)
I'm still using readlink, but the command without any argument should be portable, isn't it?
@ruduran Hi, I'm interested in implementing the same functionality (as I added support for z in mackup).
I cloned your fork and tested it on Mac OS X and it seems to work properly so I can confirm that readline
with no argument should be portable.
Have you tested it on Linux?
Yes, I did in fact develop it on Linux and it seemed to work just fine :)
@ruduran nice, thanks for confirming!
@rupa what do you think is the next step on this?
seems reasonable as it works ok with no args to readlink, wanna leave this open so i don't forget about it
Ok, I had just closed it because nobody seemed interested. Glad to see I was wrong :)
yeah im just real conservative about changing things at this point, there's enough people using this with weirdo setups that it's easy to fix things for one use case and break another. inclined to do this tho, cause if someone has some silly readlink or doesn't have it at all, the solution is "don't symlink the datafile, which you couldn't do before anyway"
As reported in #154, if the datafile is a symbolic link z overwrites it creating a regular file.
With this changes z dereferences de symlink and works with the actual file.
Any comments or suggestions are very welcome.