[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: PW#5-10: System-wide environment variables used for program config



On 14 Jan 1998, Kai Henningsen wrote:

> If program foo expects the environment variable BAR=/var/lib/fubar, an  
> easy way to make it comply to this policy is to rename foo to foo-real,  
> and write a wrapper shell script
> 
>            #! /bin/sh
>            BAR=/var/lib/fubar
>            foo-real "$@"
> 
> [I hope I got that right!]
> 
> NOTE: This may not work if the program decides what to do based on the  
> name it is called with. Fortunately, this is rare.

One thing you could do, since users are not supposed to call foo-real
directly (but should be able to do so if they really want it), you could
place it in a directory like /usr/lib/foo/ and perhaps leave the name to
be `foo'. The script would become:

#!/bin/sh
BAR=/var/lib/fubar
export BAR
exec /usr/lib/foo/foo "$@"

Note: I use `exec', I think it's better in a case like this
Note: If you don't `export' BAR, the program will not know about it

Remco


Reply to: