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

Use ln -sTf instead of ln -sf #8

Closed
MKReyesH opened this issue Oct 25, 2024 · 1 comment
Closed

Use ln -sTf instead of ln -sf #8

MKReyesH opened this issue Oct 25, 2024 · 1 comment

Comments

@MKReyesH
Copy link

The command ln behaves differently if the second argument is a link name or a directory (see https://man7.org/linux/man-pages/man1/ln.1.html).

  1. The first time the command is executed (and so no symlink exist yet) the first definition of ln is called: ln [OPTION]... [-T] TARGET LINK_NAME. And the program creates a symlink LINK_NAME pointing to TARGET, which from now on will be treated as a directory.

  2. The second time the same command is executed, as now LINK_NAME does exist and is treated as a directory, the third definition of ln is called: ln [OPTION]... TARGET... DIRECTORY, which creates a symlink of TARGET inside DIRECTORY, which in our case is the "directory" LINK_NAME which has been created in the first run.

  3. As a consequence a recursive symlink is created inside LINK_NAME, producing the following structure

LINK_NAME/
├─ Relevant files
├─ TARGET/
│  ├─ Relevant files
│  ├─ TARGET/
│  │  ├─ Relevant files
│  │  ├─ TARGET/
│  │  │  ├─ ....

which can produce unwanted results when mixed with backup or synchronization programs.

The problematic behavior can be solved by adding the --no-target-directory or -T option when creating the symlinks, which force to treat LINK_NAME as a file always, which will be overwritten when combined with the -f option.

Jannomag added a commit that referenced this issue Oct 25, 2024
Fixed nested symbolic links, thanks to @MKReyesH in #8
@Jannomag
Copy link
Owner

Jannomag commented Oct 25, 2024

Oh thanks! I noticed those nested symbolic links already but I didn't find any quick fix on this and didn't have the time to investigate completeley. This helps a lot! I already edited the shortix.sh. So updating using the desktop icon should work now. Maybe you can try it, I will later today.

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

No branches or pull requests

2 participants