diff --git a/sys/src/cmd/rc/lex.c b/sys/src/cmd/rc/lex.c index fa364f18d..662c1970a 100644 --- a/sys/src/cmd/rc/lex.c +++ b/sys/src/cmd/rc/lex.c @@ -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; diff --git a/sys/src/cmd/rc/rc.h b/sys/src/cmd/rc/rc.h index 7b7b3b343..eddad8ede 100644 --- a/sys/src/cmd/rc/rc.h +++ b/sys/src/cmd/rc/rc.h @@ -65,6 +65,7 @@ union code{ char *s; }; +int newwdir; char *promptstr; int doprompt; diff --git a/sys/src/cmd/rc/simple.c b/sys/src/cmd/rc/simple.c index ede797d30..a29359866 100644 --- a/sys/src/cmd/rc/simple.c +++ b/sys/src/cmd/rc/simple.c @@ -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; }