Help with man command

Pete French pete at
Sat Jul 15 10:54:41 BST 2006

> Which makes 'echo $PAGER' give the right result, but less didn't like
> it.  I noticed if I changed the variable from the command line, using
> 'export $PAGER=...' it works!  So, does that mean that when I set
> variables in /etc/profile I should be using 'export PAGER=...' rather
> than just 'PAGER=...'?

That rather depends on what you want them to do. Shell variables only
exist in the shell, unless you export them, when they become environment
variables and get inherited by subsequent processes. See below:

[pete at skerry ~]$ HELLO=world
[pete at skerry ~]$ echo $HELLO
[pete at skerry ~]$ sh
$ echo $HELLO

$ exit
[pete at skerry ~]$ export HELLO
[pete at skerry ~]$ sh
$ echo $HELLO
$ exit
[pete at skerry ~]$ 

So if you want the variables you set to be inherited by other programs
you should export them. In gererral most of the things you set you will
want to export I suspect, unless they are simply affecting the actual shell.


PS: This is general shell behaviour, it's not bash specific.

More information about the Ukfreebsd mailing list