3 ms·
The one that always trips me up is that `ln` is “dumb” about how it handles the first argument. If the first argument isn’t an absolute path, it must be relati
by stouset 2y ago
The one that always trips me up is that `ln` is “dumb” about how it handles the first argument.
If the first argument isn’t an absolute path, it must be relative to the second argument, and not to pwd.
ln ./foo ./bar/baz
./bar/baz will be a symlink whose literal contents are `./foo` so it will look for foo in the same directory (bar), rather than in bar’s parent directory.
This is totally backwards from how other utilities behave. Which is completely understandable if you know what it’s doing under the hood. But it is counterintuitive and surprising.
- tavianator 2y agoAt least with GNU coreutils, you can use `-r`/`--relative`
- stouset 2y agoTIL!
- bbkane 2y agoI've never internalized this, so I usually stick to using absolute paths... Not a solution for all problems, but it works for me most of the time.
- stouset 2y agoAbsolute paths will break if, for example, the target and source are in the same directory but you move the directory. Sometimes you semantically want absolute paths (I want to symlink a thing to /bin/foo), sometimes you want relative paths (I want to symlink a thing to something in a nested directory).