Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ln: last argument not treated as a directory when -n and -f are used together #5974

Closed
jansheikkinen opened this issue Feb 14, 2024 · 1 comment · Fixed by #5975
Closed
Labels

Comments

@jansheikkinen
Copy link
Contributor

Using uutils, running

$ touch a b
$ mkdir c
$ ln -snf a b c/

results in an error that says

ln: Already exists
ln: will not overwrite just-created 'c/' with 'b'

whereas, using GNU coreutils, the result is that the symlinks c/a and c/b are created successfully. However, if you run it when c doesn't exist, or when it is a file, both give an error saying ln is not a directory. If you use -n without -f, or vice versa, the symlinks are created with no problems using both versions.

I'm not entirely sure what's going on here. When c/ is a directory, its appears to want it to be a non-existing destination file to link to, whereas when c either doesn't exist or is a file, it wants it to be a directory to put the link into.

Furthermore, when c/ is a directory, the first one fails with a simple error saying the destination already exists, but the second one fails with an error that suggests it thinks linking a to c actually worked, and it just doesn't want to overwrite the same file twice.

uutils: 0.0.24
GNU: 9.4
Platform: Gentoo Linux

@tertsdiepraam
Copy link
Member

tertsdiepraam commented Feb 14, 2024

Thanks for the detailed report! I think there's indeed some faulty logic in this function:

https:/uutils/coreutils/blob/main/src/uu/ln/src/ln.rs#L295

Do you want try to submit a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants