move code to exit_shell function

This commit is contained in:
Chris Cromer 2021-06-26 19:09:41 -04:00
parent 5ce2096b2c
commit 5e5c9d8db3
2 changed files with 6 additions and 5 deletions

View File

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