diff --git a/src/boitoutil/essential_shell.c b/src/boitoutil/essential_shell.c index 5e51f60..b3102a0 100644 --- a/src/boitoutil/essential_shell.c +++ b/src/boitoutil/essential_shell.c @@ -4,7 +4,9 @@ * @date 2021 */ +#include "vars.h" #include "essential_shell.h" +#include "oui-dire.h" #include #include @@ -63,7 +65,21 @@ int native_command(char *command[]) int ret = 1; /* 0 si commande non native */ if (!strcmp(command[0], "cd")) change_dir(command[1]); - + if (!strcmp(command[0], "ouï-dire") || !strcmp(command[0], "oui-dire") + || !strcmp(command[0], "echo")) + { + char *tmp = calloc(MAX_LENGTH, sizeof(char)); + int i = 1; + while (command[i] != NULL) + { + strcat(tmp, command[i]); + *(tmp + strlen(tmp)) = ' '; + i++; + } + if (i == 2) + *(tmp + strlen(tmp) - 1) = '\0'; + echo(tmp); + } else ret = 0; return ret; diff --git a/src/boitoutil/oui-dire.c b/src/boitoutil/oui-dire.c new file mode 100644 index 0000000..6cf03f6 --- /dev/null +++ b/src/boitoutil/oui-dire.c @@ -0,0 +1,21 @@ +/** + */ + +#include "oui-dire.h" + +#include +#include +#include + +void echo(char *args) +{ + char tmp = *args; + int i = 0; + while (tmp != '\0') + { + putchar(tmp); + i++; + tmp = *(args + i); + } + putchar('\n'); +} diff --git a/src/boitoutil/oui-dire.h b/src/boitoutil/oui-dire.h new file mode 100644 index 0000000..3bd1e35 --- /dev/null +++ b/src/boitoutil/oui-dire.h @@ -0,0 +1,10 @@ +/** + */ + +#ifndef _OUIDIRE_ +# define _OUIDIRE_ + +void usage(); +void echo(char *args); + +#endif