dotter icon indicating copy to clipboard operation
dotter copied to clipboard

How to use symlinks to /dev/null ?

Open hollowshiroyuki opened this issue 2 years ago • 3 comments

Environment

If applicable, provide the following details:

  • OS: Archlinux Linux 6.6.6-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Mon, 11 Dec 2023 11:47:45 +0000 x86_64 GNU/Linux
  • Dotter version: dotter 0.13.0

The question

What is the correct way to get symlinks to /dev/null with dotter ?

For instance I don't want to have a bash history, so I can symlink .bash_history to /dev/null. When I create this link in my dotfiles directory and run dotter to apply them, dotter tries to change the ownership of the block device. Do I need to specify the root user ?

hollowshiroyuki avatar Dec 14 '23 20:12 hollowshiroyuki

I see in the code that when updating an existing symlink, if it's detected that the target location is correct the owner is still updated. I guess that changes the owner of the target of the symlink instead 🫠 I am running chown with the -h flag that is described as

  -h, --no-dereference   affect symbolic links instead of any referenced file
                         (useful only on systems that can change the
                         ownership of a symlink)

but I don't remember whether I tested this... I guess this flag doesn't work on your system, could you run chown --help and check if it's there?

I wonder if I should just drop the chown in this case altogether... IIRC ownership on the symlink file is not very important anyways.


I do see that when I'm testing that it's attempting to elevate permissions to change the ownership even though the link is already owned by the current user. Definitely need to fix the detection as it shouldn't even be attempting to elevate permissions, I guess its detecting the owner of the link's target

SuperCuber avatar Dec 14 '23 20:12 SuperCuber

yes chown on my system has the -h option with the same description as yours 👍

hollowshiroyuki avatar Dec 14 '23 21:12 hollowshiroyuki

@hollowshiroyuki, this doesn't answer your question directly, but there is another way to disable bash history. You can unset the history file with unset HISTFILE in your ~/.bashrc or ~/.bash_profile, depending on what works on your distribution. That would avoid the bug you're running into, and is the preferred way to disable history anyway. Then you can delete ~/.bash_history and it shouldn't ever get recreated unless your bash configuration fails to load.

FlippingBinary avatar Dec 21 '23 14:12 FlippingBinary