maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
loc_env_var_handler_heredoc_utils.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* loc_env_var_handler_heredoc_utils.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: rmikhayl <marvin@42.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/09/10 01:04:20 by rmikhayl #+# #+# */
9/* Updated: 2024/09/10 01:04:22 by rmikhayl ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "shell.h"
14#include "tokens.h"
15#include "redirection.h"
16#include "execute.h"
17#include <fcntl.h>
18#include <sys/wait.h>
19#include "signals.h"
20
21char *token_adj(char *arg)
22{
23 char *ptr;
24 char *new_arg;
25
26 if (*arg == '\"')
27 {
28 ptr = arg + 1;
29 while (*ptr && *ptr != '\"')
30 {
31 if (!ft_isdigit(*ptr))
32 return (ft_strdup(arg));
33 ptr++;
34 }
35 if (*ptr == '\0')
36 {
37 new_arg = malloc(ft_strlen(arg) + 2);
38 if (!new_arg)
39 return (NULL);
40 ft_strcpy(new_arg, arg);
41 ft_strcat(new_arg, "\"");
42 return (new_arg);
43 }
44 if (*ptr == '\"' && *(ptr + 1) == '\0')
45 return (ft_strdup(arg));
46 }
47 return (ft_strdup(arg));
48}
int ft_isdigit(int c)
Definition ft_isdigit.c:13
char * ft_strcpy(char *dest, const char *src)
Definition ft_strcpy.c:25
size_t ft_strlen(const char *s)
Definition ft_strlen.c:15
char * ft_strcat(char *dest, char *src)
Definition ft_strcat.c:26
char * ft_strdup(const char *s)
Definition ft_strdup.c:23
char * token_adj(char *arg)