rc: write /dev/wdir after printing the prompt, not after executing "cd" command
This commit is contained in:
parent
d39d1a5303
commit
65977417e7
3 changed files with 14 additions and 8 deletions
|
@ -92,6 +92,16 @@ pprompt(void)
|
|||
if(runq->iflag){
|
||||
pstr(err, promptstr);
|
||||
flush(err);
|
||||
if(newwdir){
|
||||
char dir[4096];
|
||||
int fd;
|
||||
if((fd=open("/dev/wdir", OWRITE))>=0){
|
||||
getwd(dir, sizeof(dir));
|
||||
write(fd, dir, strlen(dir));
|
||||
close(fd);
|
||||
}
|
||||
newwdir = 0;
|
||||
}
|
||||
prompt = vlook("prompt");
|
||||
if(prompt->val && prompt->val->next)
|
||||
promptstr = prompt->val->next->word;
|
||||
|
|
|
@ -65,6 +65,7 @@ union code{
|
|||
char *s;
|
||||
};
|
||||
|
||||
int newwdir;
|
||||
char *promptstr;
|
||||
int doprompt;
|
||||
|
||||
|
|
|
@ -139,14 +139,9 @@ int
|
|||
dochdir(char *word)
|
||||
{
|
||||
/* report to /dev/wdir if it exists and we're interactive */
|
||||
if(chdir(word)<0) return -1;
|
||||
if(flag['i']!=0){
|
||||
static int wdirfd = -2;
|
||||
if(wdirfd==-2) /* try only once */
|
||||
wdirfd = open("/dev/wdir", OWRITE|OCEXEC);
|
||||
if(wdirfd>=0)
|
||||
write(wdirfd, word, strlen(word));
|
||||
}
|
||||
if(chdir(word)<0)
|
||||
return -1;
|
||||
newwdir = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue