Built-in String Processing?

Chet Ramey chet at cwns1.INS.CWRU.Edu
Wed Oct 31 07:23:19 AEST 1990


In article <1902 at necisa.ho.necisa.oz> boyd at necisa.ho.necisa.oz (Boyd Roberts) writes:

$ With a decent* shell you just go:
$ 
$     cd()
$     {
$ 	builtin cd $1 &&
$ 	case "$1" in
$ 	'')
$ 	    PS1="% " ;;
$ 	..|*/..)
$ 	    PS1="`basename \`/bin/pwd\``% " ;;
$ 	/)
$ 	    PS1="/% " ;;
$ 	*/*)
$ 	    PS1="`basename $1`% " ;;
$ 	*)
$ 	    PS1="$1% " ;;
$ 	esac
$     }

$ * V8/V9

Don't be so elitist :-).  Bash can do this, too.  In fact, I stole this
some time ago for an example in the bash texinfo manual (which is not out
yet).  Bash doesn't make you jump through hoops quoting backquotes, either.
(so there! :-)

Chet

-- 
Chet Ramey			``As I recall, Doug was keen on boxing.  But
Network Services Group		  when he learned to walk, he took up puttin'
Case Western Reserve University	  the boot in the groin.''
chet at ins.CWRU.Edu



More information about the Comp.unix.shell mailing list