diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-06-30 00:45:37 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-06-30 00:45:37 +0200 |
commit | 65977417e7cc5919f7c9787f97a528e8c24d2423 (patch) | |
tree | 5379e98e16d10e44fd30cb45e776f54ff3f953a3 | |
parent | d39d1a5303541539f61488317b220c1eb724d7d3 (diff) | |
download | plan9front-65977417e7cc5919f7c9787f97a528e8c24d2423.tar.xz |
rc: write /dev/wdir after printing the prompt, not after executing "cd" command
-rw-r--r-- | sys/src/cmd/rc/lex.c | 10 | ||||
-rw-r--r-- | sys/src/cmd/rc/rc.h | 1 | ||||
-rw-r--r-- | sys/src/cmd/rc/simple.c | 11 |
3 files changed, 14 insertions, 8 deletions
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; } |