KSH-How do I make a variable run a function upon invocation?

1 view
Skip to first unread message

J.B. Nicholson

Apr 9, 1991, 9:24:29 PM4/9/91
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 {
case ${shrunkhome} in
${HOME}) shrunkhome=\~/ ;;
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,
| "If you hear an onion ring - answer it." J.B. Nicholson |
| je...@uiuc.edu (Internet) These opinions are mine, that's all.|

Reply all
Reply to author
0 new messages