[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Wrong interpretation og '\$' by bash?



On Sun, 2004-08-22 at 10:10, Daniel M. wrote:
> Hello everybody,
> 
> I have the following lines in ~/.bash_prompt (for all users):
> 
> ------------------------------------------------------
> # set prompt and window title (if running in X terminal)
> 
> case $TERM in
> 	xterm*)
>         	PS1="\[\033]0;\$\w/\007\]\$\w/: "
> 		;;
> 	*)
> 		PS1="\$\w/: "
> 		;;
> esac
> ------------------------------------------------------
> 
> The problem is, that when I log in as a root, '$' is displayed
> instead of '#'.
> 
> Why is that so - '\$' is supposed to display '#' if the effective 
> uid is 0, and how it can be corrected?

Quoting, I think.

Because you are using double quotes, the backslash is being interpreted
by the shell as an escape character, as if you  were specifying a
literal dollar sign.  Use single quotes instead.

-- 
Oliver Elphick                                          olly@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA  92C8 39E7 280E 3631 3F0E  1EC0 5664 7A2F A543 10EA
                 ========================================
     "For the Lord himself shall descend from heaven with a 
      shout, with the voice of the archangel, and with the 
      trump of God; and the dead in Christ shall rise first;
      Then we which are alive and remain shall be caught 
      up together with them in the clouds, to meet the Lord 
      in the air; and so shall we ever be with the Lord."   
                          I Thessalonians 4:16,17 



Reply to: