From owner-freebsd-questions Thu Jan 6 18:59:31 2000 Delivered-To: freebsd-questions@freebsd.org Received: from smtp.nwlink.com (smtp.nwlink.com [209.20.130.57]) by hub.freebsd.org (Postfix) with ESMTP id 14FAB1579C for ; Thu, 6 Jan 2000 18:59:22 -0800 (PST) (envelope-from rjoseph@nwlink.com) Received: from nwlink.com (ip74.r6.d.bel.nwlink.com [207.202.173.74]) by smtp.nwlink.com (8.9.3/8.9.3) with ESMTP id SAA14001 for ; Thu, 6 Jan 2000 18:54:34 -0800 (PST) Message-ID: <387554AC.C953BD4D@nwlink.com> Date: Thu, 06 Jan 2000 18:51:24 -0800 From: R Joseph Wright X-Mailer: Mozilla 4.51 [en] (X11; I; FreeBSD 3.4-STABLE i386) X-Accept-Language: en MIME-Version: 1.0 Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Bash prompt (Was: window manager question) References: <200001052224.XAA37273@dorifer.heim3.tu-clausthal.de> <387435D1.7E20347D@nwlink.com> <20000106175704.A7246@hades.hell.gr> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > if [[ $EUID -eq 0 ]]; then > > PS1="root@\h\w\$" > > else > > PS1="joseph@\h\w\$" > > fi > > According to the man page on bash, the "$" is supposed to show up as "#" > > if uid is 0, otherwise it will show as "$". It doesn't do this, > > however. It always shows up as "$", regardless of uid. > > Actually, when you use "\$" enclosed in double quotes, as shown above, > then bash will try and expand shell variables in the string. The dollar > sign is used to start shell variable substitutions. This would make a > prompt like "($UID) " work fine, replacing $UID with the current UID. > However, using a backslash, you can escape a `$' character, and force > bash to insert a literal `$' in that place (always speaking of double > quotes, here). > > If you don't want shell-variable substitution in the prompt value (which > happens at the time the PS1 value is evaluated, *before* it gets > assigned to PS1), then you are better off using single quotes. Try: > > PS1='\u@\h:\w\$ ' # note the single quotes! I don't fully understand what you meant about shell variables, but it works. And that's the only line I need because it automatically checks for UID and acts accordingly. -- Best Regards, Joseph You will do foolish things, but do them with enthusiasm. Colette. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message