Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ShellBuiltins/e

This file was deleted.

51 changes: 51 additions & 0 deletions ShellBuiltins/shell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

int SHa_cd(char **args);
int SHa_help(char **args);
int SHa_exit(char **args);
char *builtin_str[] = {
"cd",
"help",
"exit"
};

int (builtin_func[]) (char *) = {
&SHa_cd,
&SHa_help,
&SHa_exit
};

int SHa_num_builtins() {
return sizeof(builtin_str) / sizeof(char *);
}

int SHa_cd(char **args)
{
if (args[1] == NULL) {
fprintf(stderr, "SHa: expected argument to \"cd\"\n");
} else {
if (chdir(args[1]) != 0) {
perror("SHa");
}
}
return 1;
}

int SHa_help(char **args)
{
int i;
printf("Stephen Brennan'SHa\n");
printf("Type program names and arguments, and hit enter.\n");
printf("The following are built in:\n");

for (i = 0; i < SHa_num_builtins(); i++) {
printf(" %s\n", builtin_str[i]);
}

printf("Use the man command for information on other programs.\n");
return 1;
}

int SHa_exit(char **args)
{
return 0;
}