Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!mp.cs.niu.edu!ux1.cso.uiuc.edu!uxa.cso.uiuc.edu!jbn35564 From: jbn35564@uxa.cso.uiuc.edu (J.B. Nicholson) Newsgroups: comp.unix.questions Subject: KSH-How do I make a variable run a function upon invocation? Summary: How do I make a variable run a function but not acquire the output of it in KSH? Keywords: KSH function variable assignment substitution Message-ID: <1991Apr10.012429.11142@ux1.cso.uiuc.edu> Date: 10 Apr 91 01:24:29 GMT Sender: usenet@ux1.cso.uiuc.edu (News) Reply-To: jeffo@uiuc.edu Organization: University of Illinois at Urbana Lines: 43 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}'> ' ;; } ...then I want to define... export PS1=$(PS1) but that only works the first time I use ${PS1}. I'd like to define it as: export PS1=[just run the function called](PS1) but I don't know how to make that definition. I've tried having an alias for cd: 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 from _cd and not cd. That's rather annoying to me. Anyways, I figure keeping this whole thing inside ${PS1} would not void any warranties, cause any mayhem or incompatibilities or whatever. :-) So, basically what I'm asking is: How do I do this? Thanks in advance, Jeff -- +----------------------------------------------------------------------------+ | "If you hear an onion ring - answer it." J.B. Nicholson | +----------------------------------------------------------------------------+ | jeffo@uiuc.edu (Internet) These opinions are mine, that's all.| +----------------------------------------------------------------------------+