[nSLUG] Plems with Linux etch

Bill Davidson billdavidson at eastlink.ca
Thu Aug 23 17:00:54 ADT 2007


You wrote:
> In a reasonable sh-type shell (e.g. bash) you can type:
> echo $TERM
> to see what it's set to, and
> TERM=xterm
> to set it.  If it's not been set (unlikely!) you should export it:
> export TERM

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.

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.

> If you're running a csh-type shell, don't.  Type 'exec /bin/bash' to run
> bash instead.
> You may also get improvements if you turn off any special language or
> locale settings and use the default 'pre-internationalization' settings.
> Type:
> to do this (again, in an sh-type shell like 'bash').

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

More information about the nSLUG mailing list