[vox-tech] Bash script to setup environment variables

Henry House vox-tech@lists.lugod.org
Thu, 27 Dec 2001 23:28:31 -0800


--qDbXVdCdHGoSgWSk
Content-Type: text/plain; charset=unknown-8bit
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Dec 27, 2001 at 11:12:35PM -0800, Mark K. Kim wrote:
> Keywords: bash, script, environment variables
>=20
> I'm doing some cross-compilation work so I need to flip environment
> variables on/off in a heartbeat.  I tried to write a script, but scripts
> run on sub-processes so the changes do not take effect on the parent
> process.  Is there a way, without having to type `source script` or `.
> script`, to make environment variables changes take place on the running
> process?

Would putenv(3) work? To quote the manual:

NAME
		 putenv - change or add an environment variable

SYNOPSIS
		 #include <stdlib.h>

		 int putenv(char *string);

DESCRIPTION
		 The  putenv()  function  adds  or  changes the value of environment vari=
ables.  The
		 argument string is of the form name=3Dvalue.  If name does not already e=
xist  in  the
		 environment, then string is added to the environment.  If name does exis=
t, then the
		 value of name in the environment is changed to value.  The  string  poin=
ted  to  by
		 string becomes part of the environment, so altering the string changes t=
he environ=AD
		 ment.

--=20
Henry House
The attached file is a digital signature. See <http://romana.hajhouse.org/p=
gp>
for information.  My OpenPGP key: <http://romana.hajhouse.org/hajhouse.asc>.

--qDbXVdCdHGoSgWSk
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8LB8fKK1cAVjXujwRAqGoAKCgDFPDp+E544zLo1GDql4HFcY4pgCg6Ffi
xX1aExdfYX9INzauFt2WOJE=
=zlTn
-----END PGP SIGNATURE-----

--qDbXVdCdHGoSgWSk--