YAPQ (yet another prompt question)

Roger Gonzalez rg at unh.UUCP
Thu Aug 10 22:30:49 AEST 1989


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`
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
..

What wanted is thus "iron:rg% " for my normal state, and "iron:rg (root)# "
when I 'su'.

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.  Is there an easy way to have .cshrc figure
out that it's parent csh was spawned by make, and exit?  How about a *hard*
way?  Anything?  I tried testing $$ in .cshrc, but its only the pid of the
csh that make spawned. (Follow that?)  The only reason I'm concerned is 
that I only want a prompt when its finished.  Half hour compiles can
generate a lot of prompts:

      cc blah blah blah ......  iron:rg% iron:rg% iron:rg% iron:rg% iron:rg%
iron:rg% iron:rg% iron:rg% iron:rg% iron:rg% iron:rg% iron:rg% iron:rg% iron
:rg% iron:rg% iron:rg% iron:rg% iron:rg% iron:rg% iron:rg%
      cc .....  iron:rg% iron:rg% iron:rg% iron:rg% iron:rg% iron:rg% iron:r
g% iron:rg% iron:rg% iron:rg% iron:rg% iron:rg%

You get the idea.

Roger Gonzalez
Marine Systems Engineering Laboratory
University of New Hampshire



More information about the Comp.unix.questions mailing list