Skip to content

Commit

Permalink
clumsy cd
Browse files Browse the repository at this point in the history
  • Loading branch information
rsc committed Aug 30, 2007
1 parent fbd8857 commit 9863fea
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 9863fea

Please sign in to comment.