builtins #6

Merged
cromer merged 6 commits from builtins into master 2021-06-26 21:12:27 -04:00
2 changed files with 6 additions and 5 deletions
Showing only changes of commit 5e5c9d8db3 - Show all commits

View File

@ -16,6 +16,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include "array.h" #include "array.h"
#include "builtins.h"
bool is_builtin(char *command) { bool is_builtin(char *command) {
if (strcmp(command, "exit") == 0) { if (strcmp(command, "exit") == 0) {
@ -31,11 +32,11 @@ bool is_builtin(char *command) {
void run_builtin(StringArray *string_array) { void run_builtin(StringArray *string_array) {
if (strcmp(string_array->array[0], "exit") == 0) { if (strcmp(string_array->array[0], "exit") == 0) {
free_string_array(string_array); exit_shell(string_array);
exit(EXIT_SUCCESS);
} }
} }
void exit_shell() { void exit_shell(StringArray *string_array) {
free_string_array(string_array);
exit(EXIT_SUCCESS);
} }

View File

@ -20,5 +20,5 @@
#define _MYSHELLIN_BUILTINS #define _MYSHELLIN_BUILTINS
bool is_builtin(char *command); bool is_builtin(char *command);
void run_builtin(StringArray *string_array); void run_builtin(StringArray *string_array);
void exit_shell(); void exit_shell(StringArray *string_array);
#endif #endif