I have this in my makefile,
rcFiles = .vim .vimrc .gitconfig .hgrc .screenrc .Xresources .dircolors .bashrc .ctags .bash_completion.d
install:
@$(foreach f,$(rcFiles), [ -f $(HOME)/$f ] || ln -v -s $(PWD)/$f $(HOME)/ ; )
if .bashrc exits and I try
make install
I get
ln: creating symbolic link `/home/user/.vim': File exists
ln: creating symbolic link `/home/user/.bash_completion.d': File exists
and the process is aborted.
why no prevented this problem the conditional?
The
--forceflag makes it replace an existing linkThe
--no-dereferenceavoids creating ‘subdirectory’ links for links to directory, if the link existed already (useful for the.bash_completion.dand.vimdirs)Alternatively
To not only detect files (
-f) but also directories. You might want to explicitely check for files and directories[ -f ... || -d ... ].