blob: c669fa68553c328e28ad4ff0e3b2ec1523382f63 (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* b_h.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */
/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <stdint.h>
#include <unistd.h>
#include "d_define.h"
#include "s_struct.h"
#include "u_utils.h"
static void b_print_history_number(const char arg[])
{
(void)arg;
}
static t_bool b_check_numeric(const char arg[])
{
char *ptr;
ptr = arg;
while (*ptr != C_NUL)
{
if (ft_isdigit(*ptr) == FALSE)
{
return (FALSE);
}
ptr++;
}
return (TRUE);
}
uint8_t b_h(char *args[], t_msh *msh)
{
const uint64_t argc = u_builtins_get_argc((const char **)args);
if (argc > 1)
{
f_fail_too_many_args("h", msh);
return (127);
}
if (argc == 1 && b_check_numeric(*args) == FALSE)
{
ft_dprintf(STDERR_FILENO,
"minishell: history: %s: numeric argument required",
*args);
return (1);
}
else
{
b_print_history(*args);
}
return (0);
}
|