[PLUG] How is env initilized?

Paul Heinlein heinlein at attbi.com
Wed Nov 27 22:00:22 UTC 2002


Sorry for the long-ish quoted section, but I wanted to get the whole 
context...

> This was productive, to an extent.  I'm running Debian-Woody on all
> three servers, and the /etc/profile contains:
> 
> # /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
> # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
> 
> PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"                                                                                                                        
> if [ "$BASH" ]; then 
>   PS1='\u@\h:\w\$ ' 
> else  
>   if [ "`id -u`" -eq 0 ]; then  
>     PS1='# '    
>   else  
>     PS1='$ '    
>   fi   
> fi   
> 
> export PATH PS1  
> 
> umask 022 
> (EOF)
> 
> Which explains where the user path comes from, it is hardwired, for
> lack of a better word.  I don't understand the embedded if
> statements though.  How can the prompt string be used to modify the
> PATH (which it obviously is, why else would the export statement be
> there)?

The PS1 variable has nothing to do with PATH. If you type 'help 
export' from a bash prompt, you'll see that you can export multiple 
variables into the environment with one command.

In this case, /etc/profile is exporting PATH and PS1 at the same time;
that's all there is to it. There's no secret (or even unsecret)  
relation between the two variables.

> When I issue the command "echo $PS1", I get the the following:
> 
> \u@\h:\w\$
> 
> Not as confused, but still looking like it.

The tokens available for the bash prompt are listed in the PROMPTING 
section of the bash man page. In this case, you've got

              \u     the username of the current user
              \h     the hostname up to the first `.'
              \w     the current working directory

--Paul Heinlein <heinlein at attbi.com>





More information about the PLUG mailing list