]> CyberLeo.Net >> Repos - CDN/shlib.git/blob - lib/sh/env.sh
Add explicit copyright to all library files
[CDN/shlib.git] / lib / sh / env.sh
1 # Base environment script
2 : <<"END_OF_COPYRIGHT"
3
4 Copyright (c) 2000-2012, CyberLeo
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9
10     * Redistributions of the source code must retain the above copyright
11       notice, this list of conditions, and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright
13       notice, this list of conditions, and the following disclaimer in the
14       documentation and/or other materials provided with the distribution.
15     * Neither the name of the organization nor the names of its contributors
16       may be used to endorse or promote products derived from this software
17       without specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 HOWEVER CAUSED AND ON ANY THEORY OF LIABILTY, WHETHER IN CONTRACT, STRICT
27 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
28 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 END_OF_COPYRIGHT
31
32 if [ -z "${__env_sh_loaded}" ]
33 then
34   if [ -z "${_root}" -o ! -d "${_root}" ]
35   then
36     printf "\033[1;31mSet _root to the directory containing lib/sh before sourcing this file!\033[0m\n"
37     kill $$
38   fi
39   
40   __env_sh_loaded=yes
41
42   realpath() {
43     ( cd "${1}"; pwd )
44   }
45
46   __env_libdir="$(realpath "${_root}/lib/sh")"
47   want() {
48     while [ -n "${1}" ]
49     do
50       if [ -f "${__env_libdir}/${1}.sh" ]
51       then
52         . "${__env_libdir}/${1}.sh"
53       else
54         printf "\033[1;31mFailed to load '${1}'\033[0m\n"
55       fi
56       shift
57     done
58   }
59   
60   err() {
61     echo " ** ${*}"
62     exit 1
63   }
64 fi