johnston@Lbl-Csam.ARPA (04/18/84)
From: (Bill Johnston [csam])johnston@Lbl-Csam.ARPA Why is it the case that having "set prompt" in your .cshrc file instead of your .login file inhibits vi from interpreting file names of the form "~username/file"?
cak@Purdue.ARPA (04/18/84)
From: Christopher A Kent <cak@Purdue.ARPA> Be sure to only "set prompt" if you're in an interactive shell; this solves the problem. Check for being in an interactive shell: if ( $?prompt ) then interactive stuff endif Cheers, chris ----------
chris@umcp-cs.UUCP (04/23/84)
If you "set prompt" in your .cshrc without carefully first checking
whether "prompt" was already set, then the C shell will cheerfully
print prompts into the pipe vi uses to expand glob characters. If
you say ":e abc*", vi opens a pipe to the C-shell and writes the
command "echo abc*" down the pipe, then reads the response. If the
response contains spaces or newlines, vi gets confused. If you set
your prompt in your .cshrc, vi tends to get "(1) abc.file (2)" back
from the C-shell, instead of just "abc.file".
The solution is to kludge your .cshrc like this:
if ($?prompt) then
# things to do for an interactive shell, like:
set prompt='(\!) '
endif
This works because a non-interactive shell doesn't have a prompt
set, while an interactive shell has it set to "% ".
If you have a large .cshrc, this can speed things up quite a bit
when programs run other programs with "csh -c 'command'", if you
put all of it inside that test.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci (301) 454-7690
UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet: chris@umcp-cs ARPA: chris@marylandebk@iedl02.UUCP (04/26/84)
> Why does set prompt in .cshrc instead of .login screw up vi.
When a shell is not interactive, such as those forked by vi with input
and output as pipes, it doesn't print prompts (obviously). Not so obvious
is the kludgy way the prompt is prevented: instead of checking a flag
before printing the prompt, the prompt string is set to null at startup.
If you then set prompt=something, the something will be output as well as
the filename that vi is looking for. (Also try :!ls - your prompt will
appear twice as well as the output.) It doesn't hurt anything in .login,
since .login isn't read by secondary shells.
The correct way to set the prompt is in the .cshrc, but in an if:
if {$?prompt} set prompt=myprompt
John Owens