maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
loc_env_var_handler_utils_utils_utils.c File Reference
#include "tokens.h"
Include dependency graph for loc_env_var_handler_utils_utils_utils.c:

Go to the source code of this file.

Functions

char * exit_status_adj (char *arg)
 
int is_in_single_quotes (char *arg)
 
char * str_start_adj (char *arg)
 
char * tmp_adj (char *arg)
 
char * append_literal (char **start, char *processed_arg)
 

Function Documentation

◆ append_literal()

char * append_literal ( char **  start,
char *  processed_arg 
)

Definition at line 74 of file loc_env_var_handler_utils_utils_utils.c.

75{
76 char *literal_part;
77 char *literal_start;
78 char *tmp;
79
80 literal_start = *start;
81 while (**start != '\0' && **start != '$')
82 (*start)++;
83 literal_part = ft_substr(literal_start, 0, *start - literal_start);
84 tmp = ft_strjoin(processed_arg, literal_part);
85 free(literal_part);
86 free(processed_arg);
87 return (tmp);
88}
char * ft_substr(char const *s, unsigned int start, size_t len)
Definition ft_substr.c:27
char * ft_strjoin(char const *s1, char const *s2)
Definition ft_strjoin.c:23

References ft_strjoin(), and ft_substr().

Referenced by process_argument().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exit_status_adj()

char * exit_status_adj ( char *  arg)

Definition at line 21 of file loc_env_var_handler_utils_utils_utils.c.

22{
23 if (ft_strcmp(arg, "$") == 0)
24 return ("$?");
25 return (arg);
26}
int ft_strcmp(const char *s1, const char *s2)
Definition ft_strcmp.c:24

References ft_strcmp().

Referenced by expand_env_and_loc_var().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_in_single_quotes()

int is_in_single_quotes ( char *  arg)

Definition at line 28 of file loc_env_var_handler_utils_utils_utils.c.

29{
30 int len;
31
32 if (!arg || arg[0] != '\'')
33 return (0);
34 len = 0;
35 while (arg[len] != '\0')
36 len++;
37 if (arg[len - 1] == '\'')
38 return (1);
39 return (0);
40}

Referenced by post_process_command_args().

Here is the caller graph for this function:

◆ str_start_adj()

char * str_start_adj ( char *  arg)

Definition at line 42 of file loc_env_var_handler_utils_utils_utils.c.

43{
44 if (!ft_strcmp(arg, "?") || !ft_strcmp(arg, "?\""))
45 return ("");
46 else if (!ft_strcmp(arg, "?\'"))
47 return ("\'");
48 return (arg);
49}

References ft_strcmp().

Referenced by expand_variable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tmp_adj()

char * tmp_adj ( char *  arg)

Definition at line 51 of file loc_env_var_handler_utils_utils_utils.c.

52{
53 char *ptr;
54 char *tmp_adj_dup;
55
56 if (*arg == '\"')
57 {
58 ptr = arg + 1;
59 while (*ptr)
60 {
61 if (!ft_isdigit(*ptr))
62 return (arg);
63 ptr++;
64 }
65 tmp_adj_dup = ft_strdup(arg + 1);
66 free(arg);
67 return (tmp_adj_dup);
68 }
69 tmp_adj_dup = ft_strdup(arg);
70 free(arg);
71 return (tmp_adj_dup);
72}
int ft_isdigit(int c)
Definition ft_isdigit.c:13
char * ft_strdup(const char *s)
Definition ft_strdup.c:23

References ft_isdigit(), and ft_strdup().

Referenced by append_expanded_var().

Here is the call graph for this function:
Here is the caller graph for this function: