martin f krafft wrote: > ln behaves differently, and IMHO wrongly. ln -sf baz bar should be > overwriting the symlink bar with a new one pointing to baz.
You are tripping into a classic BSD v. SysV difference. This is not portable: mkdir bar ln -s bar foo ln -fs baz foo This is portable: mkdir bar ln -s bar foo rm -f foo ln -fs baz foo BSD systems will treat symlinks transparently. If the symlink points to a directory then the new target will be made in the directory. SysV systems will detect that the target is a symlink and replace the symlink. I personally find the SysV behavior much more intuitive. Mike Stone wrote: > POSIX mandates that symlinks be treated as the object they reference > (in your case, as a directory) by default, unless some specific > option is specified to treat the symlink specially, or if the > command is intended to interact with symlinks. Unfortunately I don't have the time at the moment to look up the POSIX requirements but I believe this particular issue is in a grey area of POSIX to allow SysV systems to claim to follow POSIX but also to replace target symlinks in traditional SysV behavior. BSD behavior has traditionally pushed through the symlink and since symlinks originated with BSD that behavior has been preferred by most users and therefore by GNU ln. I know this has been a long term difference between BSD and SysV. The only portable strategy is to remove the target first to ensure that it does not exist before creating a new one. I have been tripped up on this point by moving scripts from HP-UX to BSD and GNU systems. I believe the POSIX issue is whether ln is allowed to or required to unlink the target before creating the I don't think POSIX requires this particular behavior. Unfortunately I don't have time to research this topic at the moment and so am adding these notes from my vague memory unverified. In any case this has been discussed upstream a number of times previously and I don't believe there is any momentum to change this from the BSD behavior. I don't think Debian should deviate from the GNU behavior. Bob
signature.asc
Description: Digital signature

