YAPQ (yet another prompt question)
Gregory Kemnitz
kemnitz at mitisft.Convergent.COM
Fri Aug 11 14:13:21 AEST 1989
In article <1356 at unhd.unh.UUCP> rg at unh.UUCP (Roger Gonzalez) writes:
I tried to send you mail, but the mailer croaked...
>
>I got some mail about my questions, but I guess I wasn't specific enough.
>Let me try again...
>
>Uniplus+ System V, Release 2:
>
>Since a child 'csh' is spawned whenever I 'su', I thought it would be
>nice to have the prompt reflect the 'su-ed' state. Hence, in .cshrc, I
>had:
>
>(assume $host = 'iron' and $user1 = 'rg')
>
>..
>set user2 = `whoami`
^^^^^^
spelling out "who am i" is more portable
>if ($user2 == 'root') then
> set suffix = '# '
>else
> set suffix = '% '
>endif
>
>if ($user1 == $user2) then
> set prompt = $host':'$user1$suffix
>else
> set prompt = $host':'$user1' ('$user2')'$suffix
>endif
Sorry, but I have no answer for this - csh's on older sysV's can be flaky.
There are lots of quotes here - maybe check that.
But some changes in logic would be a quick fix to do the same thing:
<setting stuff>
if ($user2 == 'root') then
set prompt = $host':'$user1' (root) # '
else
set prompt = $host':'$user1'% '
endif
It's as portable and (slightly) more efficient.
> [stuff deleted]
>The first instance works, but when I su I get:
>error in set (or something similar)
>iron:rg_
>
>My second question had to do with 'make'. Setting the prompt in .cshrc
>seems to make it appear when you are running make and it spawns a shell
>to handle cd's and the like.
> [more make stuff deleted]
>
>Roger Gonzalez
>Marine Systems Engineering Laboratory
>University of New Hampshire
If you set your SHELL variable to /bin/sh (and have no prompt setting stuff in
your .profile) before running make you won't have this problem - or you can
take the prompt stuff and put it in your .login, but obviously you won't be able
to do the type of prompt stuff you describe above.
If you do use the SHELL trick, remember to set your SHELL variable back after
running make - otherwise your su's will run the Bourne shell.
----------------------------------+--------------------------------------
Greg Kemnitz | Software without hardware is an idea.
kemnitz at Convergent.COM | Hardware without software is a space heater.
soon: |
kemnitz at postgres.berkeley.edu | --Unknown author
More information about the Comp.unix.questions
mailing list