Package: bash
Version: 3.2-4
Severity: wishlist

There's nothing in /etc/skel/.profile about setting environment
variables. Now that dash is /bin/sh, it's worth trying to do this nicely.

I make the following suggestion; I welcome improvements.

In my ~/.profile, I have at the top:

# Specify environment
ENV=$HOME/.shvars; export ENV
BASH_ENV=$ENV; export BASH_ENV

and at the bottom:

# Load environment variables
if [ -n "$ENV" ]; then . "$ENV"; fi

The placing of these lines is so far fairly arbitrary; the only
important point in my setup is that the sourcing of $ENV is done at
the bottom because my .shvars modifies $PATH. Proper treatment of this
depends on a fix for bug #379696, which I don't presume to address
here.

These changes achieve the following thing (with a bit more
documentation, which I'd be happy to write if the changes were
adopted):

1. Give the user an obvious place to set environment variables. I
   would also add /etc/skel/.shvars, containing some comments pointing
   out that you need to use POSIX syntax, i.e. 'FOO="bar"; export FOO'
   rather than 'export FOO="bar"'.

2. Make the environment variables available to all /bin/sh and
   /bin/bash scripts (via BASH_ENV and ENV).

The main problem I foresee is that users might want different sets of
variables available in interactive from non-interactive sessions.
Hence, it might be better to recommend two variables files, say
~/.shvars and ~/.shvars_interactive, where ~/.shvars_interactive
includes and overrides ~/.shvars (this way round seems more useful to
me than the other way around, though either would work) and set ENV
and BASH_ENV to ~/.shvars as above, but source ~/.shvars_interactive
instead. But maybe this is an unnecessary complexity. (I certainly
don't have a need for it at present.)

I just spent some time working all this out to get environment
variables working nicely in GNOME without having manually to load an
environment anywhere, so I suspect that something of this sort could
save other users time, as well as promoting good practice.

-- System Information:
Debian Release: 5.0.4
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-2-686 (SMP w/1 CPU core)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages bash depends on:
ii  base-files                5lenny5        Debian base system miscellaneous f
ii  debianutils               2.30           Miscellaneous utilities specific t
ii  libc6                     2.7-18lenny2   GNU C Library: Shared libraries
ii  libncurses5               5.7+20081213-1 shared libraries for terminal hand

Versions of packages bash recommends:
ii  bash-completion               20080705   programmable completion for the ba

Versions of packages bash suggests:
pn  bash-doc                      <none>     (no description available)

-- no debconf information



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to