Git init
[pkgs/e/elektra.git] / doc / standards / env.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!--
4
5 Subversion stuff
6
7 $Id$
8
9 -->
10
11 <!--
12
13 This specification-by-example defines an easier, more direct and more precise
14 way for applications to set aliases and env vars for a user session.
15
16 It will, in some ways, substitute the functionality of the files
17
18         /etc/profile
19         ~/.profile
20         ~/.bashrc
21         ~/.bash_profile
22
23 Although on those files some can add code and some logic to define env vars,
24 this key schema is usefull when you just want to set environments in an
25 atomic way.
26
27 The /etc/profile.d/elektraenv.sh script loads the environments declared by
28 the keys in this schema.
29
30 The key hierarchy proposed (as examples) is:
31
32 Systemwide environments, as in /etc/profile:
33         system/
34           env/
35             env1/
36               JAVA_HOME              = /opt/IBMJava2
37             env2/
38               PATH                   = $PATH:$JAVA_HOME/bin
39               LIBPATH                = $LIBPATH:$JAVA_HOME/lib
40             env3/
41               EDITOR                 = vi
42             alias/
43               ll                     = ls -l
44
45 User specific environment (loaded after system's), as in ~/.profile
46         user/
47           env/
48             env1/
49             env2/
50               PATH                   = $PATH:~/bin
51               LIBPATH                = $LIBPATH:~/lib
52             env3/
53               PS1                    = \h:\w\$ 
54               EDITOR                 = kate
55             alias/
56               ls                     = ls -Fh -color=auto
57               ll                     = ls -l -Fh -color=auto
58               vi                     = gvim -x
59
60 Note that we have env1, env2 and env3 levels.
61 Thats because a script has a natural order for the things to happen, so we
62 can easily define $PATH using $JAVA_HOME, but after defining $JAVA_HOME.
63 Since there is no such natural order when accessing keys and values, the
64 elektraenv script will fetch env1, env2, env3 in this order, then envvars
65 can be defined dependent on previously defined other envvars, as
66 with $PATH depending on $JAVA_HOME.
67
68 In addition, the elektraenv script will fetch system/env keys before it
69 fetches user/env keys.
70
71 Avi Alkalay <avi@unix.sh>
72 Nov 2005
73
74 -->
75 <keyset xmlns="http://www.libelektra.org"
76         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
77         xsi:schemaLocation="http://www.libelektra.org elektra.xsd">
78
79 <!-- The systemwide environment and aliases -->
80         <keyset parent="system/env/env1">
81                 <key basename="JAVA_HOME" value="/opt/IBMJava2"/>
82         </keyset>
83
84
85         <keyset parent="system/env/env2">
86                 <key basename="PATH">
87                         <value>$PATH:$JAVA_HOME/bin</value>
88                         <comment>Since we are under env2, and $JAVA_HOME was defined in env1, at this point, $JAVA_HOME is already set.</comment>
89                 </key>
90                 
91                 <key basename="LIBPATH" value="$LIBPATH:$JAVA_HOME/lib"/>
92         </keyset>
93
94
95         <keyset parent="system/env/env3">
96                 <key basename="EDITOR" value="vi"/>
97         </keyset>
98
99
100         <keyset parent="system/env/alias">
101                 <key basename="ll" value="ls -l"/>
102         </keyset>
103
104
105
106
107 <!-- The user specific environment and aliases -->
108         <keyset parent="user/env/env2">
109                 <key basename="PATH"    value="$PATH:~/bin"/>
110                 <key basename="LIBPATH" value="$LIBPATH:~/lib"/>
111         </keyset>
112         
113         
114         <keyset parent="user/env/env3">
115                 <key basename="PS1"    value="\h:\w\$ "/>
116                 <key basename="EDITOR" value="kate"/>
117         </keyset>
118                 
119                 
120         <keyset parent="user/env/alias">
121                 <key basename="ls" value="ls -Fh --color=tty"/>
122                 <key basename="ll" value="ls -l -Fh --color=tty"/>
123                 <key basename="vi" value="gvim -x"/>
124         </keyset>
125
126 </keyset>