Newsgroups: comp.unix.shell Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!ukma!s.ms.uky.edu!eric From: eric@ms.uky.edu (Eric H. Herrin II) Subject: Re: KSH-How do I make a variable run a function upon invocation? Message-ID: Keywords: KSH function variable assignment substitution Organization: University Of Kentucky, Dept. of Math Sciences References: <1991Apr10.035042.3008@ux1.cso.uiuc.edu> Date: Thu, 11 Apr 1991 21:39:32 GMT Lines: 37 jbn35564@uxa.cso.uiuc.edu (J.B. Nicholson) writes: >In KSH I want to make ${PS1} take on a value where it executes a function called >PS1, but not take on the output from the function itself. Here's what I mean: >function PS1 { >shrunkhome=${PWD%${HOME}/} >case ${shrunkhome} in > ${HOME}) shrunkhome=\~/ ;; >esac >HOSTNAME=$(hostname) >print -n '<'${USER}'@'${HOSTNAME%%.*}':'${shrunkhome}'> ' ;; >} Try this: function _cd { unalias cd cd $1 alias cd=_cd if [ "${PWD#${HOME}}" != "${PWD}" ] then PS1='"${USER}@${HOSTNAME%%.*}:~/${PWD#${HOME}}> "' else PS1='"${USER}@${HOSTNAME%%.*}:${PWD}> "' fi } and alias cd to '_cd' as you suggested in your original article. I did test this and it does work. (ksh version 11/16/88d) You might want to put some error checking in the _cd function though. -- | Eric H. Herrin II - {rutgers,uunet}!ukma!eric, eric@ms.uky.edu |