6static void read_line (
char line[],
size_t);
7static bool backspace (
char **pos,
char line[]);
12 printf (
"Shell starting...\n");
22 if (!
strcmp (command,
"exit"))
24 else if (!
memcmp (command,
"cd ", 3))
26 if (!
chdir (command + 3))
27 printf (
"\"%s\": chdir failed\n", command + 3);
29 else if (command[0] ==
'\0')
37 printf (
"\"%s\": exit code %d\n", command,
wait (pid));
78 if (pos < line + size - 1)
static void wait(struct intq *q, struct thread **waiter)
int putchar(int c)
Writes C to the vga display and serial port.
int printf(const char *format,...)
Writes formatted output to the console.
bool chdir(const char *dir)
Project 4 only.
pid_t exec(const char *file)
int read(int fd, void *buffer, unsigned size)
int pid_t
Process identifier.
#define EXIT_SUCCESS
Typical return values from main() and arguments to exit().
static bool backspace(char **pos, char line[])
If *POS is past the beginning of LINE, backs up one character position.
static void read_line(char line[], size_t)
Reads a line of input from the user into LINE, which has room for SIZE bytes.
#define STDIN_FILENO
Include lib/user/stdio.h or lib/kernel/stdio.h, as appropriate.
int memcmp(const void *a_, const void *b_, size_t size)
Find the first differing byte in the two blocks of SIZE bytes at A and B.
int strcmp(const char *a_, const char *b_)
Finds the first differing characters in strings A and B.