Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!news.nd.edu!mentor.cc.purdue.edu!sage.cc.purdue.edu!asg From: asg@sage.cc.purdue.edu (Bruce Varney) Newsgroups: comp.unix.shell Subject: Re: KSH-How do I make a variable run a function upon invocation? Keywords: KSH function variable assignment substitution Message-ID: <10009@mentor.cc.purdue.edu> Date: 10 Apr 91 14:39:28 GMT Article-I.D.: mentor.10009 References: <1991Apr10.035042.3008@ux1.cso.uiuc.edu> Sender: news@mentor.cc.purdue.edu Reply-To: asg@sage.cc.purdue.edu (Bruce Varney) Organization: Purdue University Lines: 43 In article <1991Apr10.035042.3008@ux1.cso.uiuc.edu> jeffo@uiuc.edu 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: } }alias -x cd='_cd' } }and a function (defined before that alias was set) called _cd that basically }assigns ${PS1} to the right value somewhat similar to above, except passing }arguments to the REAL cd program (to maintain compatibility) but every time }I access cd, won't this function _cd run? Also, all my error messages come }Thanks in advance, } Jeff Here is the scoop - there are two possibilities The first and easiest (IMHO) is to switch shells to bash. bash has a variable PROMPT_COMMAND which is a command to run before the prompt is printed. Thus you could do something line PS1="\$WD ->" PROMPT_COMMAND = "WD = `working_dir`" working_dir() { whatever you use to prune the dir name } Course if you are stuck on ksh, this will also work. Note that it will not work with csh as ksh and csh handle aliases different alias -x x=cd alias -x cd='cd_help' cd_help() { whatever you use to prune the dir name x $1 } that will work just fine (or should). Hope this helps As Always The Grand Master --------- ### ## Courtesy of Bruce Varney ### # aka -> The Grand Master # asg@sage.cc.purdue.edu ### ##### # PUCC ### # ;-) # # ;'> # ##