summaryrefslogtreecommitdiff
path: root/sh.c
diff options
context:
space:
mode:
authorrsc <rsc>2007-08-30 18:30:26 +0000
committerrsc <rsc>2007-08-30 18:30:26 +0000
commit9863fea78cf88b40827d0d61ced2608278094ea4 (patch)
tree9310760d7e2452039439f65b0079d7053cb5935b /sh.c
parentfbd8857d4d5edcbf97185d95fa57406d36e75b7b (diff)
downloadxv6-labs-9863fea78cf88b40827d0d61ced2608278094ea4.tar.gz
xv6-labs-9863fea78cf88b40827d0d61ced2608278094ea4.tar.bz2
xv6-labs-9863fea78cf88b40827d0d61ced2608278094ea4.zip
clumsy cd
Diffstat (limited to 'sh.c')
-rw-r--r--sh.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sh.c b/sh.c
index 7a7c4c2..100bbdc 100644
--- a/sh.c
+++ b/sh.c
@@ -157,6 +157,14 @@ main(void)
// Read and run input commands.
while(getcmd(buf, sizeof(buf)) >= 0){
+ if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
+ // Clumsy but will have to do for now.
+ // Chdir has no effect on the parent if run in the child.
+ buf[strlen(buf)-1] = 0; // chop \n
+ if(chdir(buf+3) < 0)
+ printf(2, "cannot cd %s\n", buf+3);
+ continue;
+ }
if(fork1() == 0)
runcmd(parsecmd(buf));
wait();