6 # Defines the environment variables used by the personalized unix
8 # Author: Chris Koeritz
12 #hmmm: moved from functions.sh; does that hose everything up?
14 # defines a variable within the feisty meow environment and remembers that
15 # this is a new or modified definition. if the feisty meow codebase is
16 # unloaded, then so are all the variables that were defined.
17 # this function always exports the variables it defines.
18 function define_yeti_variable()
20 #hmmm: simple implem just sets it up and exports the variable.
21 # i.e., this method always exports.
24 #hmmm: eventual approach-- if variable exists already, save old value for restore,
25 # otherwise save null value for restore,
26 # have to handle unsetting if there was no prior value of one
28 # add variable name to a list of feisty defined variables.
36 # this section should always run or bash will reset them on us.
37 # these need to be as minimal as possible.
39 # sets the main prompt to a simple default, with user@host.
40 define_yeti_variable PS1='\u@\h $ ';
41 # sets the history length and max file size so we can get some long history around here.
42 define_yeti_variable HISTSIZE=1000000
43 define_yeti_variable HISTFILESIZE=8000000
45 # make the TERM available to all sub-shells.
46 define_yeti_variable TERM
50 # we'll run this again only if we think it's needed.
51 if [ -z "$CORE_VARIABLES_LOADED" ]; then
53 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then echo variables initialization begins...; fi
57 # start with some simpler things.
59 define_yeti_variable SCRIPT_SYSTEM=feisty_meow
61 # OS variable records the operating system we think we found.
63 define_yeti_variable OS=UNIX
65 define_yeti_variable IS_DARWIN=$(echo $OSTYPE | grep -i darwin)
69 # guess the current platform.
70 IS_UNIX=$(uname | grep -i linux)
71 if [ -z "$IS_UNIX" ]; then IS_UNIX=$(uname | grep -i unix); fi
72 if [ -z "$IS_UNIX" ]; then IS_UNIX=$(uname | grep -i darwin); fi
73 IS_DOS=$(uname | grep -i ming)
74 if [ -z "$IS_DOS" ]; then IS_DOS=$(uname | grep -i cygwin); fi
76 # now if we're stuck in DOS, try to determine the type of system.
77 if [ ! -z "$IS_DOS" ]; then
78 # IS_MSYS will be non-empty if this is the msys toolset. otherwise
79 # we assume that it's cygwin.
80 IS_MSYS=$(uname | grep -i ming)
82 # if not MSYS, then we'll assume cygwin and set the cygwin root var.
83 if [ -z "$IS_MSYS" ]; then
84 define_yeti_variable CYGROOT=$(cygpath -w -m /)
90 # fallbacks to set crucial variables for feisty meow...
92 # set the main root directory variable for the feisty meow codebase.
93 # this is only used for extreme failure modes, when the values were not
94 # pulled in from our auto-generated config.
95 if [ -z "$FEISTY_MEOW_APEX" ]; then
96 if [ -d "$HOME/feisty_meow" ]; then
97 define_yeti_variable FEISTY_MEOW_APEX="$HOME/feisty_meow"
98 define_yeti_variable FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_SCRIPTS"
102 # main declaration of the transients area.
103 if [ -z "$TMP" ]; then
104 define_yeti_variable TMP=$HOME/.tmp
107 # set up the top-level for all build creations and logs and such.
108 if [ -z "$FEISTY_MEOW_GENERATED_STORE" ]; then
109 define_yeti_variable FEISTY_MEOW_GENERATED_STORE="$TMP/generated-feisty_meow"
111 if [ ! -d "$FEISTY_MEOW_GENERATED_STORE" ]; then
112 mkdir -p "$FEISTY_MEOW_GENERATED_STORE"
114 # set up our effluent outsourcing valves.
115 if [ -z "$TEMPORARIES_PILE" ]; then
116 define_yeti_variable TEMPORARIES_PILE="$FEISTY_MEOW_GENERATED_STORE/temporaries"
118 if [ ! -d "$TEMPORARIES_PILE" ]; then
119 mkdir -p "$TEMPORARIES_PILE"
122 # similarly, make sure we have someplace to look for our generated files, if
123 # we were not handed a value.
124 if [ -z "$FEISTY_MEOW_LOADING_DOCK" ]; then
125 # The generated scripts directory is where automatically generated files live.
126 # It is separate from the main body of the shell scripts in order to keep things from
128 define_yeti_variable FEISTY_MEOW_LOADING_DOCK=$HOME/.zz_feisty_loading
133 # set up the color_add variable which is a flag that lets ls know colors work.
135 # test if we can use color in ls...
136 ls --help 2>&1 | grep -i -q color
137 if [ $? -eq 0 ]; then
138 export color_add='--color=auto'
146 # umask sets a permission mask for all file creations.
147 # this mask disallows writes by "group" and "others".
149 # this mask disallows writes by the "group" and disallows "others" completely.
152 # ulimit sets user limits. we set the maximum allowed core dump file size
153 # to zero, because it is obnoxious to see the core dumps from crashed
154 # programs lying around everywhere.
159 # user variables, sort of... if they haven't given themselves a name yet,
160 # then we will make one up for them.
162 # define a default name, if one wasn't already set.
163 if [ -z "$NAME" ]; then
164 define_yeti_variable NAME='Unset Q. Namington, Fixley Your Name III'
169 # variables for perl.
171 define_yeti_variable PERLLIB+="/usr/lib/perl5"
172 define_yeti_variable PERL5LIB+="/usr/lib/perl5"
173 if [ "$OS" == "Windows_NT" ]; then
174 define_yeti_variable PERLIO=:perlio
175 # choose perl's IO over the ms-windows version so we can handle file
179 # iterate across our sub-directories and find the perl scripts.
180 # this currently only looks one level down.
181 for i in $FEISTY_MEOW_SCRIPTS/*; do
183 # check if there is a perl file present; add the folder to PERLLIB if so.
184 ls $i/*.pl &>/dev/null
185 if [ $? -eq 0 ]; then
186 PERLLIB+=":$(dos_to_unix_path $i)"
187 PERL5LIB+=":$(dos_to_unix_path $i)"
191 #echo PERLLIB is now $PERLLIB
195 # set this so nechung can find its data.
196 define_yeti_variable NECHUNG=$FEISTY_MEOW_APEX/infobase/fortunes.dat
198 ## # establish a pipe for less to see our beloved syntax highlighting.
199 ## define_yeti_variable LESSOPEN="| source-highlight -f esc -o STDOUT -i %s"
201 # the base checkout list is just to update feisty_meow. additional folder
202 # names can be added in your customized scripts. the space at the end of
203 # this variable is important and allows users to extend the list like:
204 # define_yeti_variable REPOSITORY_DIR+="muppets configs"
205 # see the customize/fred folder for a live example.
206 define_yeti_variable REPOSITORY_LIST="$FEISTY_MEOW_APEX "
208 # add in any active projects to the repository list.
209 if [ -d "$HOME/active" ]; then
210 REPOSITORY_LIST+="$(find "$HOME/active" -maxdepth 1 -mindepth 1 -type d) "
212 # add in any site avenger applications that are in the apps folder.
213 if [ -d "$HOME/apps" ]; then
214 # first, simple projects.
215 REPOSITORY_LIST+="$(find "$HOME/apps" -iname "avenger5" -type d) "
216 # then, site avenger specific projects.
217 REPOSITORY_LIST+="$(find "$HOME/apps" -maxdepth 2 -mindepth 2 -iname "avenger5" -type d) "
220 # the archive collections list is a set of directories that are major
221 # repositories of data which can be synched to backup drives.
222 define_yeti_variable ARCHIVE_COLLECTIONS_LIST=
224 # initializes the feisty meow build variables, if possible.
225 function initialize_build_variables()
228 # we need to know the feisty meow directory, or we bail.
229 if [ -z "$FEISTY_MEOW_APEX" ]; then return; fi
230 # pick from our expected generator folder, but make sure it's there...
231 buildvars="$FEISTY_MEOW_SCRIPTS/generator/build_variables.sh"
232 if [ -f "$buildvars" ]; then
233 # yep, that one looks good, so pull in the build defs.
234 source "$buildvars" "$buildvars"
237 # now augment the environment if we found our build variables.
238 if [ $found_build_vars == 1 ]; then
239 # the binary directory contains our collection of handy programs.
240 define_yeti_variable FEISTY_MEOW_BINARIES=$TARGETS_STORE
241 # add binaries created within build to the path.
242 define_yeti_variable PATH="$(dos_to_unix_path $FEISTY_MEOW_BINARIES):$PATH"
243 # Shared libraries are located via this variable.
244 define_yeti_variable LD_LIBRARY_PATH="$(dos_to_unix_path $LD_LIBRARY_PATH):$(dos_to_unix_path $FEISTY_MEOW_BINARIES)"
250 # windoze specific patching up missing things.
252 if [ "$OS" == "Windows_NT" ]; then
253 define_yeti_variable HOSTNAME=$(echo $HOSTNAME | tr A-Z a-z)
258 # load in the build environment.
259 initialize_build_variables
263 # add to the PATH variables used for locating applications. this step is taken after any
264 # potential overrides from the user.
265 define_yeti_variable PATH="$(dos_to_unix_path $FEISTY_MEOW_LOADING_DOCK):$PATH:$(find /usr/local/games -maxdepth 1 -type d -exec echo -n {}: ';' 2>/dev/null)/sbin"
269 # set the SHUNIT_PATH so our shunit tests can find the codebase.
270 define_yeti_variable SHUNIT_PATH="$FEISTY_MEOW_SCRIPTS/shunit"
274 define_yeti_variable CORE_VARIABLES_LOADED=true
276 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then echo variables initialization ends....; fi
281 # pull in the custom overrides for feisty_meow scripts. this is done last,
282 # because we want to set everything up as expected, then let the user
283 # override individual variables and definitions. we also don't guard this
284 # to avoid running it again, because we don't know what mix of functions and
285 # aliases they want to define in there.
286 for i in $FEISTY_MEOW_LOADING_DOCK/custom/*.sh; do
287 if [ ! -f "$i" ]; then
288 # skip it if it's not real.
291 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
292 echo "loading customization: $(basename $(dirname $i))/$(basename $i)"