I would like to install something from github in a bash script but I try to verify if the folder exists or not:
BLUE "Installing LS_COLORS..."
if [ ! -d "~/opt/LS_COLORS" ]
then
git clone https://github.com/trapd00r/LS_COLORS.git ~/opt/LS_COLORS && cd ~/opt/LS_COLORS
cat lscolors.sh >> ~/.bashrc
source ~/.bashrc
else
GREEN "LS_COLORS already installed"
fi
The problem is that the LS_COLORS dir does not empty and this is not working properly. I can not get into the else part.
~
). Please rewrite your script with absolute paths, and revise your post with the complete script with absolute paths. – Artur Meinild Oct 26 '22 at 13:19cd
throughout the entire script, which is not as reliable. – Artur Meinild Oct 26 '22 at 13:43~
per se - it's the fact that it's quoted. See for example Why isn't tilde recognised as home folder in this case? – steeldriver Oct 26 '22 at 13:45~
is as absolute as$HOME
is - see for example Is~/Documents
a relative or an absolute path? – steeldriver Oct 26 '22 at 14:14$HOME
would be the best option. – Artur Meinild Oct 26 '22 at 15:13