Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!sun-barr!newstop!sun!amdcad!dgcad!dg-rtp!wgate!lanzo From: lanzo@wgate.UUCP (Mark Lanzo) Newsgroups: comp.unix.shell Subject: Re: adjusting string var to fixed length (in ksh) Keywords: ksh, typeset Message-ID: <193@atesysv.UUCP> Date: 12 Jun 91 20:54:21 GMT References: <9106111833.AA07449@ucbvax.Berkeley.EDU> Reply-To: lanzo@atesysv.UUCP (Mark Lanzo) Organization: Wandel & Goltermann Technologies, Inc. Lines: 37 "Mark" == Mark Lanzo [that's me] "Dan" == Dan_Jacobson@ihlpz.ATT.COM From prior posts: Mark> If you are using "ksh" [...] Mark> myname=Mark Mark> typeset -L10 myname Dan> In my prompt I wanted to put $? (last command exit status) in a fixed Dan> width... (PS1='$? '...) but I can't typeset -L3 ? or \?... Hmm. As far as I know, you're out of luck with this. You're right, "typeset" doesn't work on special parameters like "$?"; it just complains that "?" isn't a valid identifier. Even if "typeset" _did_ work on $?, I think you'd still be out of luck. Ksh evaluates PS1 and performs *parameter substitution* on the string, but it does not perform *command substitution* on it. (Drats!) In other words, you can't use the `command` or $(command) forms within PS1 in any meaningful fashion. For example, to display the current directory in the prompt: PS1='$PWD> ' # Works PS1='`pwd`> ' # Does not work PS1='$(pwd)> ' # Does not work I even tried screwier things, to see if any sort of recursive evaluation mechanisms could be faked out, such as PS1='${?:+`pwd`}' ... to no avail. If anyone else has a solution, I'd like to hear about it ... -- Mark --