summaryrefslogtreecommitdiff
path: root/sh.c
blob: 9d4a308957c2cfaca0bcc35a46dd62a34a9512d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "user.h"
#include "types.h"
#include "fs.h"
#include "fcntl.h"

char *args[100];

int
main(void)
{
  char buf[128];
  int pid;

  while(1){
    puts("$ ");
    gets(buf, sizeof(buf));
    if(buf[0] == '\0')
      continue;
    pid = fork();
    if(pid == 0){
      args[0] = buf;
      args[1] = 0;
      exec(buf, args);
      printf(1, "%s: not found\n", buf);
      exit();
    }
    if(pid > 0)
      wait();
  }
}