Article View: comp.unix.shell
Article #1674Re: Built-in String Processing?
From: Chet Ramey
Date: Tue, 30 Oct 1990 20:23
Date: Tue, 30 Oct 1990 20:23
35 lines
1453 bytes
1453 bytes
In article <1902@necisa.ho.necisa.oz> boyd@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@ins.CWRU.Edu
Technical Details
Message-ID:
<1990Oct30.202319.20762@usenet.ins.cwru.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!usenet.ins.cwru.edu!cwns1!chetReferences:
<1990Oct27.215051.14085@midway.uchicago.edu> <1902@necisa.ho.necisa.oz>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!usenet.ins.cwru.edu!cwns1!chet From: chet@cwns1.INS.CWRU.Edu (Chet Ramey) Newsgroups: comp.unix.shell Subject: Re: Built-in String Processing? Message-ID: <1990Oct30.202319.20762@usenet.ins.cwru.edu> Date: 30 Oct 90 20:23:19 GMT References: <1990Oct27.215051.14085@midway.uchicago.edu> <1902@necisa.ho.necisa.oz> Sender: news@usenet.ins.cwru.edu Reply-To: chet@po.CWRU.Edu Organization: Case Western Reserve Univ. Cleveland, Ohio, (USA) Lines: 36 Nntp-Posting-Host: cwns1.ins.cwru.edu