Re: Script to Set Environment Variable?
Hello
ms419@freezone.co.uk (<ms419@freezone.co.uk>) wrote:
> How do I write a script to set an environment variable?
>
> I feel like I should know this. I want to set my PATH in pbuilder &
> the author suggested using an "A" hook. However, I can't create a hook
> - an executable - which sets an environment variable.
>
> I tried:
>
> #!/bin/sh
> export PATH=/usr/lib/ccache:$PATH
>
> and just:
>
> export PATH=/usr/lib/ccache:$PATH
>
> but in either case, calling ./A10hook doesn't change my environment
> variable. I hope I'm just missing something foolishly obvious.
Yes. The script is run in a subshell, sets the variable, and when the
script is finished, the subshell terminates. You need to set the
variable in the current shell. Run
. ./A10hook
best regards
Andreas Janssen
--
Andreas Janssen <andreas.janssen@bigfoot.com>
PGP-Key-ID: 0xDC801674 ICQ #17079270
Registered Linux User #267976
http://www.andreas-janssen.de/debian-tipps-sarge.html
Reply to: