]> CyberLeo.Net >> Repos - CDN/Mosi.git/blob - script/lib/env.sh
Initial commit
[CDN/Mosi.git] / script / lib / env.sh
1 # Base environment script
2
3 if [ -z "${__env_sh_loaded}" ]
4 then
5   if [ -z "${_root}" -o ! -d "${_root}" ]
6   then
7     printf "\033[1;31mSet _root to the directory containing lib/ before sourcing this file!\033[0m\n"
8     kill $$
9   fi
10   
11   __env_sh_loaded=yes
12
13   realpath() {
14     ( cd "${1}"; pwd )
15   }
16
17   __env_libdir="$(realpath "${_root}/lib")"
18   want() {
19     while [ -n "${1}" ]
20     do
21       if [ -f "${__env_libdir}/${1}.sh" ]
22       then
23         . "${__env_libdir}/${1}.sh"
24       else
25         printf "\033[1;31mFailed to load '${1}'\033[0m\n"
26       fi
27       shift
28     done
29   }
30   
31   err() {
32     echo " ** ${*}"
33     exit 1
34   }
35 fi