rg@unh.UUCP (Roger Gonzalez) (08/08/89)
I seem to have a problem with spaces in my prompt. It ignores them. Any suggestions? Also, is there any way to keep 'make' from spitting out a prompt after every step? Roger Gonzalez Marine Systems Engineering Laboratory University of New Hampshire
rg@unh.UUCP (Roger Gonzalez) (08/10/89)
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
kemnitz@mitisft.Convergent.COM (Gregory Kemnitz) (08/11/89)
In article <1356@unhd.unh.UUCP> rg@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@Convergent.COM | Hardware without software is a space heater. soon: | kemnitz@postgres.berkeley.edu | --Unknown author
moeller@uniol.UUCP (Klaus Moeller) (08/11/89)
rg@unh.UUCP (Roger Gonzalez) writes: >I seem to have a problem with spaces in my prompt. It ignores them. >Any suggestions? Use the " sign for the prompt. For example PS1="hello you" >Also, is there any way to keep 'make' from spitting out a prompt >after every step? Use the @ sign before every instruction in the Makefile
guy@auspex.auspex.com (Guy Harris) (08/12/89)
>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. Or set it in the Makefile instead, and save yourself (and anybody else running "make" with that Makefile) the trouble of remembering to set it before running "make" and set it back after doing so.
jik@athena.mit.edu (Jonathan I. Kamens) (08/12/89)
In article <1157@mitisft.Convergent.COM> kemnitz@mitisft.UUCP (Greg Kemnitz) writes: >In article <1356@unhd.unh.UUCP> rg@unh.UUCP (Roger Gonzalez) writes: >>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. >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. This avoids the problem rather than solving it. What if Roger *wants* make to use csh as its shell? The correct answer is that his .cshrc should be checking to see if the prompt is already set to something before it sets it. Since make starts up a non-interactive shell, the prompt will not be set to anything automatically by csh before it processes the .cshrc. Therefore, if every instance of "set prompt =" in .cshrc is replaced with "if ($?prompt) set prompt =" the problem will go away. Jonathan Kamens USnail: MIT Project Athena 432 S. Rose Blvd. jik@Athena.MIT.EDU Akron, OH 44320 Office: 617-253-4261 Home: 216-869-6432
aland@infmx.UUCP (Dr. Scump) (08/15/89)
In article <1356@unhd.unh.UUCP> rg@unh.UUCP (Roger Gonzalez) writes: | |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_ | |Roger Gonzalez Did you try su-ing to uid that definitely has csh as its shell? I suspect that root on your system uses sh by default. sh(1) would gag on the "set prompt" command, as it is not valid set syntax for sh. -- Alan S. Denney @ Informix Software, Inc. {pyramid|uunet}!infmx!aland "I want to live! -------------------------------------------- as an honest man, Disclaimer: These opinions are mine alone. to get all I deserve If I am caught or killed, the secretary and to give all I can." will disavow any knowledge of my actions. - S. Vega
jik@athena.mit.edu (Jonathan I. Kamens) (08/16/89)
In article <2113@infmx.UUCP> aland@infmx.UUCP (alan denney) writes: =In article <1356@unhd.unh.UUCP> rg@unh.UUCP (Roger Gonzalez) writes: =| =|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: =|[problem text deleted] =Did you try su-ing to uid that definitely has csh as its shell? =I suspect that root on your system uses sh by default. sh(1) would =gag on the "set prompt" command, as it is not valid set syntax =for sh. Ahem. Since when does /bin/sh even look for a file called ".cshrc" when it starts up? The characters "csh" in the filename ".cshrc" are significant, no? Jonathan Kamens USnail: MIT Project Athena 432 S. Rose Blvd. jik@Athena.MIT.EDU Akron, OH 44320 Office: 617-253-4261 Home: 216-869-6432
abcscnge@csuna.csun.edu (Scott "The Pseudo-Hacker" Neugroschl) (08/22/89)
In article <13542@bloom-beacon.MIT.EDU> jik@athena.mit.edu (Jonathan I. Kamens) writes: ]>In article <2113@infmx.UUCP> aland@infmx.UUCP (alan denney) writes: ]=In article <1356@unhd.unh.UUCP> rg@unh.UUCP (Roger Gonzalez) writes: ]=| ]=|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: ]=|[problem text deleted] [various flames deleted] Since Roger is obviousely using csh, how about the following alias su '/bin/su \!:* -c "exec csh"' That ought to always force a csh invocation of the su, without the parent sh hanging around... -- Scott "The Pseudo-Hacker" Neugroschl UUCP: ...!sm.unisys.com!csun!csuna.csun.edu!abcscnge -- Beat me, Whip me, make me code in Ada -- Disclaimers? We don't need no stinking disclaimers!!!
abcscnge@csuna.csun.edu (Scott "The Pseudo-Hacker" Neugroschl) (08/23/89)
>rg@unh.UUCP (Roger Gonzalez) writes: >Also, is there any way to keep 'make' from spitting out a prompt >after every step? Two ways: 1) put the line: SHELL=/bin/sh at the top of your makefile 2) in your .cshrc use the (regrettably undocumented feature): if ( $?prompt ) then # interactive shell stuff (including prompt) here endif The second method will also have the effect of speeding up C-shell scripts. The "if ( $?prompt ) then" says do this ONLY if the shell variable "prompt" is set. It is only set on interactive shells. Scott -- Scott "The Pseudo-Hacker" Neugroschl UUCP: ...!sm.unisys.com!csun!csuna.csun.edu!abcscnge -- Beat me, Whip me, make me code in Ada -- Disclaimers? We don't need no stinking disclaimers!!!