diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
| commit | 967be9e750221ab2ab783f95df79bb26d290a45e (patch) | |
| tree | 6802900a5e975f9f68b169f0f503f040056d6952 /42sh/src/builtins/continue.c | |
Diffstat (limited to '42sh/src/builtins/continue.c')
| -rw-r--r-- | 42sh/src/builtins/continue.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/42sh/src/builtins/continue.c b/42sh/src/builtins/continue.c new file mode 100644 index 0000000..295fb8c --- /dev/null +++ b/42sh/src/builtins/continue.c @@ -0,0 +1,27 @@ +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "builtins.h" +#include "utils/env.h" + +int my_continue(struct string **args) +{ + char *n = "1"; + if (args[0] != NULL) + { + char *end; + long num = strtol(args[0]->data, &end, 10); + if (*end != '\0' || num <= 0) + { + fprintf(stderr, "continue: %s: numeric argument required\n", + args[1]->data); + return 2; + } + n = args[0]->data; + } + env_set("CONTINUE", n); + fflush(stdout); + return 0; +} |
