From owner-freebsd-questions Sat Oct 16 17:57:38 1999 Delivered-To: freebsd-questions@freebsd.org Received: from athserv.otenet.gr (athserv.otenet.gr [195.170.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 6796214CE7 for ; Sat, 16 Oct 1999 17:57:30 -0700 (PDT) (envelope-from keramida@diogenis.ceid.upatras.gr) Received: from hades.hell.gr (patr530-a057.otenet.gr [195.167.115.57]) by athserv.otenet.gr (8.9.3/8.9.3) with SMTP id DAA01661 for ; Sun, 17 Oct 1999 03:57:47 +0300 (EET DST) Received: (qmail 1901 invoked by uid 1001); 17 Oct 1999 00:59:04 -0000 To: freebsd-questions@freebsd.org Subject: Re: bash's "\$" in PS1 doesn't work right References: <87g0zbxmdg.fsf@main.wgaf.net> <87aepjxlrk.fsf@main.wgaf.net> From: Giorgos Keramidas Date: 17 Oct 1999 03:59:04 +0300 In-Reply-To: Arcady Genkin's message of "16 Oct 1999 13:23:27 -0400" Message-ID: <86ogdyn6p3.fsf@localhost.hell.gr> Lines: 30 X-Mailer: Gnus v5.6.45/XEmacs 21.1 - "20 Minutes to Nikko" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Arcady Genkin writes: > Arcady Genkin writes: > > > I have the following in .bashrc: > > export PS1="\h:\w\$ " > > > > However, the "\$" doesn't result in "#" for root. I get the "$" sign. > > > "set" reports: > > PS1='\h:\w$ ' The reason is that bash tries to do variable substitution when you use double quotes, so the "\$ " thing means to bash: do not use the dollar sign for shell variable substitution, but use it as a single dollar sign. If you had used export PS1="\\h:\\w:\\\$ " it would have worked without a glitch, but this backslashing can end up in a true nightmare once you get to use nested expressions in the prompt, say the output of some command like `uname -r` somewhere in there. The solution is to use single quotes for anything that you don't care to have the shell substitute as a shell variable somewhere. Something like: export PS1='\h:\w\$ ' -- Giorgos Keramidas, "That field hath eyen, and the wood hath ears." [Geoffrey Chaucer, 1328-1400] To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message