`pwd` in Shell prompt

Doug Gwyn gwyn at brl-smoke.ARPA
Sat Apr 2 00:14:33 AEST 1988


In article <12747 at brl-adm.ARPA> H235-017%IRLEARN.BITNET at cunyvm.cuny.edu (Mark Humphrys) writes:
>I want to get the current directory to be automatically included in the Shell
>prompt.

Not again!  This was beaten to death a few months ago.
The answer is, a "vanilla" Bourne shell cannot update the PS1
string before every prompt (but the Korn shell can).  A Bourne
shell that does not support shell functions (e.g. the one shipped
with Berkeley UNIX) cannot update the PS1 (prompt) string as a
side-effect of executing a command to change directories, but
shells with shell functions can.  The vanilla SVR2 Bourne shell
does not permit shell functions to have the same names as
builtins, so such a command would have to be called something
other than "cd" (e.g. "ch").  The BRL Bourne shell, like the 8th
Edition UNIX shell that inspired some of its features, permits
builtins to be displaced by shell functions, so for example my
"cd" either updates the PS1 string on simple terminals or updates
the window banner on fancy terminals (e.g. AT&T 630 or Sun).

By the way, most people simply type "pwd" when they need to know
what their current working directory is.



More information about the Comp.unix.questions mailing list