I need to set the environment variables, usually we do this by
source script.sh
But now, I am automating it during the boot process and it
tl;dr With sh
(as opposed to bash
) the argument must contain a slash: source ./script.sh
, not just source script.sh
. Unless script.sh
can be found in PATH
.
Dot (.
) command exists in both bash
and sh
. Additionally, bash
aliases it as source
. From bash
manual:
https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html#index-source
source
source filename
A synonym for
.
(see Bourne Shell Builtins).
https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html#index-_002e
. (a period)
. filename [arguments]
Read and execute commands from the
filename
argument in the current shell context. Iffilename
does not contain a slash, thePATH
variable is used to find filename. When Bash is not in POSIX mode, the current directory is searched iffilename
is not found in$PATH
.
From POSIX:
If
file
does not contain a/
, the shell shall use the search path specified byPATH
to find the directory containing file. Unlike normal command search, however, the file searched for by the dot utility need not be executable.