Bourne shell modifications, past and future

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Fri Nov 29 11:27:29 AEST 1985


> > ....Functions subsume aliases very nicely, so chuck
> >aliases!  Don't have funny % sequences in prompt strings when `uname`
> >or `pwd` will work fine.
> 
> The problem is that PS1="`pwd` " will only evaluate pwd once, and one would
> want whatever the directory is now. Same with PS1="$PWD ". Which is why I
> use funny % sequences. At least no one else uses them.

But you can get this to work nicely if you redefine the "cd"
built-in as a shell function (if your shell functions work like
8th Ed. UNIX and not like SVR2).  Since I have an SVR2 shell,
I can't redefine "cd", so I use "ch" instead.  Here `tis:

ch(){			# should be cd
	if [ $# -lt 1 ]
	then	cd	# should be built-in cd
	else	cd $1	# ditto
	fi
	PS1=`uname | sed s/\^brl-// | tr '[a-z]' '[A-Z]'`:`pwd`'$ '
}

Yes, this is a more elaborate PS1, but it makes the point.

Berkeley users just have to suffer, but then they are so used to that
that they have probably convinced themselves that everything is great.
It's nice of you to try to help them out.



More information about the Comp.unix mailing list