Homebrew / homebrew-linux-fonts

πŸ–‹ Formula of οΌ¦πŸ…Ύπ“π“πš‚ (fork of Caskroom-fonts)
BSD 2-Clause "Simplified" License
50 stars 5 forks source link

docs: avoid creating symlink inside symlink to fonts #36

Closed robsonpeixoto closed 1 year ago

robsonpeixoto commented 1 year ago

A simple ln -s TARGET LINK_NAME will by default create a symlink with the name LINK_NAME if LINK_NAME is a file or will create a symlink inside LINK_NAME if LINK_NAME is a directory. For example:

$ ln -sv /home/linuxbrew/.linuxbrew/share/fonts ~/.local/share/fonts
'/home/my-user/.local/share/fonts' -> '/home/linuxbrew/.linuxbrew/share/fonts'

$ ln -sv /home/linuxbrew/.linuxbrew/share/fonts ~/.local/share/fonts
'/home/my-user/.local/share/fonts/fonts' -> '/home/linuxbrew/.linuxbrew/share/fonts'

$ ln -sv /home/linuxbrew/.linuxbrew/share/fonts ~/.local/share/fonts
ln: failed to create symbolic link '/home/my-user/.local/share/fonts/fonts': File exists

The parameter --no-dereference will tread the LINK_NAME as a file avoiding such problem:

$ ln --verbose --symbolic --no-dereference /home/linuxbrew/.linuxbrew/share/fonts ~/.local/share/fonts
'/home/my-user/.local/share/fonts' -> '/home/linuxbrew/.linuxbrew/share/fonts'

$ ln --verbose --symbolic --no-dereference /home/linuxbrew/.linuxbrew/share/fonts ~/.local/share/fonts
ln: failed to create symbolic link '/home/my-user/.local/share/fonts': File exists
tani commented 1 year ago

Thank you for revising our document. I would like to suggest the ln -s src -t dirname instead of your approach.

$ ln -s /home/linuxbrew/.linuxbrew/share/fonts -t ~/.local/share

I noticed that there still remains a problem in your approach.

$ mkdir ~/.local/share/fonts
$ ln --verbose --symbolic --no-dereference /home/linuxbrew/.linuxbrew/share/fonts ~/.local/share/fonts
'/home/tani/.local/share/fonts/fonts' -> '/home/linuxbrew/.linuxbrew/share/fonts'

Would you mind checking this behaviour? Best regards,

robsonpeixoto commented 1 year ago

I agree with you, @tani! Your solution is better.

tani commented 1 year ago

Anyway, thank you for your contribution!