blob: 6718de196847e3f289b1459b118afdf2f3b0ebdb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "builtins.h"
#include "utils/env.h"
int my_break(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, "break: %s: numeric argument required\n",
args[1]->data);
return 2;
}
n = args[0]->data;
}
env_set("BREAK", n);
fflush(stdout);
return 0;
}
|