[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Generating an environment setting script
From: |
Alexander Malmberg |
Subject: |
Generating an environment setting script |
Date: |
Mon, 26 Jul 2004 03:14:30 +0200 |
Hi,
During some recent discussions of GNUstep.sh in #GNUstep (and, in
particular, of problems using it with various shells), Andrew Ruder
suggested a script that generates a script that sets the environment
(instead of having a GNUstep.sh that both figures out what it needs to
set in the environment _and_ sets the environment). Thence:
http://w1.423.telia.com/~u42308495/alex/GNUstep2.sh.tar.gz
Put the two new files and apply the patch in core/make/, re-configure,
re-'make install', and run (not source)GNUstep2.sh (which needs a better
name :). It will print a script to stdout that, when sourced, sets the
environment (for the user that ran GNUstep2.sh, based on current
configuration). Eg. GNUstep.sh.in can then be reimplemented as
(roughly):
eval "`@prefix@/@MAKEFILES_SUFFIX@/GNUstep2.sh`"
if [ -f "$GNUSTEP_USER_ROOT/GNUstep.sh" ]; then
. "$GNUSTEP_USER_ROOT/GNUstep.sh"
fi
# make_services stuff here
For GNUstep.csh.in, you'd give GNUstep2.sh a single argument "csh",
which makes it print a csh script.
The advantages would be:
1. GNUstep2.sh only needs to run on /bin/sh. No need to maintain
multiple scripts for building all the path lists and stuff.
2. GNUstep2.sh runs in a real sub-shell, so you don't have to be
paranoid about what you do to the environment.
3. Supporting new shells is just a matter of writing a new case of
script generator; the rest of GNUstep2.sh is unaffected. (And since the
resulting script is very simple, there are fewer portability problems
with it.)
and as a bonus, :)
4. You can redirect the output to a file and get a configuration-cache
of sorts: a really simple and really fast script that sets your
environment. (And note that setting the environment is, deliberately,
all the generated script does.)
Comments? Thoughts?
- Alexander Malmberg
- Generating an environment setting script,
Alexander Malmberg <=