coreutils "ln" created bad symbolic link when I believe it should have failed , because the symbolic link being created already existed.

Created a directory "AA"

Created symbolic link  "aa" to directory "./AA"

Created directory "BB"

Created symbolic link to  "aa" to "./BB", without first deleting the original symbolic link "aa".

Symbolic link creation of "aa" should fail on line 43 of test (ln -s ./BB aa), because symbolic link "aa" already exists. No error was reported and it created a bad symbolic link, inside directory "AA" as "BB" to "./BB" ( see line 53 of test),

Symbolic link "aa" to directory "AA" remained.

glenn@cottage:~/ZZ> ln --version
ln (GNU coreutils) 9.6
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Parker and David MacKenzie.

-------------- test follows

glenn@cottage:~/ZZ> ls -lR
.:
total 0
glenn@cottage:~/ZZ> mkdir AA
glenn@cottage:~/ZZ> ls -lR
.:
total 0
drwxr-xr-x 2 glenn glenn 6 Feb 27 16:13 AA

./AA:
total 0
glenn@cottage:~/ZZ> ln -s ./AA aa
glenn@cottage:~/ZZ> ls -lR
.:
total 0
lrwxrwxrwx 1 glenn glenn 4 Feb 27 16:13 aa -> ./AA
drwxr-xr-x 2 glenn glenn 6 Feb 27 16:13 AA

./AA:
total 0
glenn@cottage:~/ZZ> mkdir BB
glenn@cottage:~/ZZ> ls -lR
.:
total 0
lrwxrwxrwx 1 glenn glenn 4 Feb 27 16:13 aa -> ./AA
drwxr-xr-x 2 glenn glenn 6 Feb 27 16:13 AA
drwxr-xr-x 2 glenn glenn 6 Feb 27 16:14 BB

./AA:
total 0

./BB:
total 0
glenn@cottage:~/ZZ> *ln -s ./BB aa*
glenn@cottage:~/ZZ> ls -lR
.:
total 0
lrwxrwxrwx 1 glenn glenn  4 Feb 27 16:13 aa -> ./AA
drwxr-xr-x 2 glenn glenn 16 Feb 27 16:14 AA
drwxr-xr-x 2 glenn glenn  6 Feb 27 16:14 BB

./AA:
total 0
*lrwxrwxrwx 1 glenn glenn 4 Feb 27 16:14 BB -> ./BB*

./BB:
total 0
glenn@cottage:~/ZZ>

Thanks
Glenn.

Reply via email to