[nSLUG] Plems with Linux etch

Daniel Morrison draker at gmail.com
Thu Aug 23 22:19:15 ADT 2007

On 23/08/07, Bill Davidson <billdavidson at eastlink.ca> wrote:

> Not to be pedantic, but there seems to be some misunderstanding of "export"
> here.  Use of the operator "export" has nothing to do with whether or not
> the variable in question is already defined.  Rather, simple assignment
> (eg., TERM=linux) means that you are setting that variable to have that
> value *in the current shell only*.  Using "export" (eg., export TERM=linux)
> means that you are setting that variable to have that value in the current
> shell *and all sub-shells*.  Any executable shell script run in the current
> shell is actually run in a sub-shell (unless it is sourced), so if you don't
> export environment variables they will not be seen in the executing script.

Yes, you are correct.  I didn't make any of this clear in my example.

> So, for example, let't assume that frob-apt is a new whiz-bang debian
> package manager which is a shell-script.  Suppose you determine that $TERM
> is currently set to vt100 and that breaks the fancy ANSI coulour output in
> frob-apt, but the man page (you read the man page, right?) says evrything
> will work if $TERM is xterm.  So you type TERM=xterm, then type "echo $TERM"
> and voila, it says xterm.  Then you run frob-apt, which is executed in a
> subshell, and in that subshell TERM is still vt100 because you didn't export
> the new value, and so it still doesn't work right.

No, not quite. Once the variable has been exported, you don't need to
export it again, even if you change it.  This is why I said it should be
exported if it hadn't been set yet... I was making the assumption that if
it had been set, then it had also been exported.  Playing a little fast
and loose, I know.  But typically, if the system profile scripts set
$TERM, then it's also been exported.  So you can simply type 'TERM=xterm'
and frob-apt (or dselect) will work with the xterm TERM type.  If TERM had
been unset, then after setting again it's necessary to export it once

> > If you're running a csh-type shell, don't.  Type 'exec /bin/bash' to run
> > bash instead.

Actually I expected to get more flak for this tongue and cheek
statement... no tcsh cheerleaders around?  :)

> > LANG=C

> Also, "export LC_ALL=C", or at least make sure $LC_ALL isn't set.  It takes
> precedence over $LANG

Thanks for pointing this out.  I'm not very good at localization stuff.


More information about the nSLUG mailing list