Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!sdd.hp.com!apollo!vinoski From: vinoski@apollo.hp.com (Stephen Vinoski) Newsgroups: comp.unix.shell Subject: Re: adjusting string var to fixed length (in ksh) Keywords: ksh, typeset Message-ID: <1991Jun13.151112.15311@apollo.hp.com> Date: 13 Jun 91 15:11:12 GMT References: <9106111833.AA07449@ucbvax.Berkeley.EDU> <193@atesysv.UUCP> Sender: netnews@apollo.hp.com (USENET posting account) Organization: Hewlett-Packard Company, Apollo Division - Chelmsford, MA Lines: 28 Nntp-Posting-Host: bull.ch.apollo.hp.com In article <193@atesysv.UUCP> lanzo@atesysv.UUCP (Mark Lanzo) writes: >"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. If your ksh is newer than the 06/86 version, how about this: typeset -L3 st=0 trap 'st=$?' DEBUG PS1='$st ' -steve | Steve Vinoski (508)256-0176 x5904 | Internet: vinoski@apollo.hp.com | | HP Apollo Division, Chelmsford, MA 01824 | UUCP: ...!apollo!vinoski |