[SunHELP] /bin/sh
Will Mc Donald
sunhelp at sunhelp.org
Tue Jul 31 18:00:33 CDT 2001
ksh supports prompt customisation, this *might* work with sh but I don't
have a Solaris box handy right now to test. Personally I don't see what the
hassle is with logging in then just typing bash or ksh or whatever. However,
don't change root's shell under any circumstances! :)
(Search engines are your friend...)
http://www.google.com/search?hl=en&safe=off&q=ksh+prompt+custom&spell=1
http://help.unc.edu/cgi-bin/getdocs?docnumber=cus03.2
<begin quoted bit>
Setting the shell prompt
Setting a custom prompt in the Korn shell works differently than in some
other shells. In some C and T shells, as well as in the popular bash from
the Free Software Foundation, the information in the prompt can be
customized by using special escape sequences (characters preceded by \).
This is not true in the Korn shell. Another difference is in the exact
variable used to specify the prompt. Under the C and T shells, there is only
one, the shell variable prompt. In ksh, there are actually four variables
used for prompting. Only one of these, however, is really useful to most
users, so we will ignore the others for now.
PS1
The PS1 variable holds your primary prompt string. Each time you execute a
command at the shell prompt, variable expansion is performed upon the value
of PS1, with the result being displayed as your new prompt. There are
several different pieces of information which might be useful to have in the
prompt, such as the current directory, username, or command number.
The prompt variables, such as PS1, are initialized much like any other
variable. But there is one important fact to remember: variable expansion is
performed on the prompt string every time you execute a command. It is thus
possible to embed a variable name in the prompt variable and have the prompt
updated after each command. Consider the following prompt initialization:
PS1='$PWD$ '
This initializes PS1 to the string "$PWD$ ." The built-in variable PWD
always holds the path to your current working directory, so at each command
the prompt string is expanded to show your path as the prompt, followed by
the standard ksh $ prompt. But why isn't expansion peformed at the time PS1
is first initialized? One would think that PS1 should simply hold the
working directory path at the time of initialization and thereafter always
show the same string. To understand why this is not the case, we have to
briefly discuss the shell quoting conventions. When a variable is contained
in double quotes ("x"), the variable will be expanded if passed as an
argument to any command. But notice that in the initialization command
above, the variable is inside single quotes. Inside single quotes, no
variable expansion can take place -- the $ is interpreted literally, rather
than as denoting a variable name.
</end quoted bit>
----- Original Message -----
From: "David Baldwin" <dbaldwin at networkinsight.com>
To: <sunhelp at sunhelp.org>
Sent: Tuesday, July 31, 2001 8:20 PM
Subject: RE: [SunHELP] /bin/sh
> Thanks for the response.
> I heard that there was this little problem and a way around it. For one
> reason or another we need to use /bin/sh for root but I would like the
> little added convenience of the prompt with the current working dir.
> For the life of me, I just can't remember the work around.
> Thanks though.
> Dave Baldwin
>
More information about the SunHELP
mailing list