I want to add a directory to the
$PATH environment variable through an install script. I have written a few programs, all present in one directory. They need a lot of other packages installed to run. So I also wrote an installation script to install all the dependencies. All of that is fine. However, what I finally need to do is to also add the directory to the search path, preferably directly through the installation script, and then do
source ~/.profile as well from the script itself if possible.
So basically, I would like to write a script that basically adds a directory to the search path permanently if not previously present. I can do the "if not present part". I, however, did not find any resources on how to add the path safely to
.profile through a script. Is it not advisable to do so?
I think I can try deleting the line containing the
sed and append the new one to the
.profile file. I do not want to try that and risk messing something up unless I am absolutely sure.