Let us say I have the following script files:
~/src/setup.sh::
#!/usr/bin/env bash
dn=$( dirname "$0" )
source "$dn/init/init.sh"
~/src/init/init.sh:
#!/usr/bin/env bash
dn=$( dirname "$0" )
source "$dn/start.sh"
start_servers "param1" "param2"
~/src/init/start.sh:
#!/usr/bin/env bash
start_servers() {
# ...
printf "start the servers..."
# ...
}
Sourcing the second file (start.sh) results that:
$ ./setup.sh
./init/init.sh: line 4: ./start.sh: No such file or directory
./init/init.sh: line 6: start_servers: command not found
Since I execute the setup.sh from .
, after sourcing the files, start.sh seems to be sourced from .
as well but I would like to source it from its proper location.
Any idea how to fix it? Thanks in advance.