Typo!

I found a typo (well, a misstatement) in the famous prompt magic article (originally here at ibm’s site).

The problem I found deals with the use of the escape sequence for indicating privileges in your prompt. In other words, the sequence that becomes $ if you are a regular user and # if you have root privileges. The escape sequence as it is written is \$… but that displays a $ all the time.

For some reason, the solution to this problem involves using a double backslash with double quotes, or a single backslash with single quotes. Observe this example where I use sudo su to become root:

me@mybox:~$ export PS1="\$ "
$ sudo su
$ exit
exit
$ export PS1="\$ "
$ sudo su
# exit
exit
$ export PS1='\$ '
$ sudo su
# exit
exit
$

As you can see, using the single backslash with double quotes doesn’t make the prompt character change when I become root. However, when the number of backslashes agrees with the type of quotes there is no problem.

I notified the author of the problem and explanation.