File tree 1 file changed +26
-3
lines changed
1 file changed +26
-3
lines changed Original file line number Diff line number Diff line change 3
3
/* ::: :::::::: */
4
4
/* shell.c :+: :+: :+: */
5
5
/* +:+ +:+ +:+ */
6
- /* By: relkabou <relkabou@student.42.fr> +#+ +:+ +#+ */
6
+ /* By: relkabou <relkabou@student.1337.ma> +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* Created: 2023/02/01 00:04:46 by relkabou #+# #+# */
9
- /* Updated: 2023/02/05 16:52:03 by relkabou ### ########.fr */
9
+ /* Updated: 2023/02/10 12:27:49 by relkabou ### ########.fr */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
13
13
#include "minishell.h"
14
14
15
+ static int is_space (char c );
16
+ static void ft_add_history (char * line );
17
+
15
18
void shell_loop (void )
16
19
{
17
20
char * line ;
@@ -23,7 +26,7 @@ void shell_loop(void)
23
26
line = readline (PROMPT );
24
27
if (!line )
25
28
break ;
26
- add_history (line );
29
+ ft_add_history (line );
27
30
cmd = parse_line (line );
28
31
if (g_global .heredoc_flag )
29
32
{
@@ -38,3 +41,23 @@ void shell_loop(void)
38
41
free (line );
39
42
}
40
43
}
44
+
45
+ static void ft_add_history (char * line )
46
+ {
47
+ char * ptr ;
48
+
49
+ ptr = line ;
50
+ if (!line )
51
+ return ;
52
+ while (* line && is_space (* line ))
53
+ {
54
+ line ++ ;
55
+ }
56
+ if (* line != 0 )
57
+ add_history (ptr );
58
+ }
59
+
60
+ static int is_space (char c )
61
+ {
62
+ return (c == ' ' || (c >= '\t' && c <= '\r' ));
63
+ }
You can’t perform that action at this time.
0 commit comments