fix: "echo $" works
This commit is contained in:
parent
72ff3ba134
commit
b3d060874d
BIN
.nfs00000000098c816100000162
Executable file
BIN
.nfs00000000098c816100000162
Executable file
Binary file not shown.
@ -4,5 +4,7 @@
|
||||
# include "../libftx/libftx.h"
|
||||
# include "../env/env.h"
|
||||
# include "../utils/utils.h"
|
||||
|
||||
char *get_pwd(int fd);
|
||||
|
||||
#endif
|
||||
|
@ -10,5 +10,6 @@ typedef struct s_data
|
||||
int child_pid;
|
||||
} t_data;
|
||||
|
||||
t_data *ft_get_data();
|
||||
t_data *ft_get_data(void);
|
||||
|
||||
#endif
|
||||
|
7
env/env_fill.c
vendored
7
env/env_fill.c
vendored
@ -22,6 +22,8 @@ static char *ft_getkey(const char *str)
|
||||
key = ft_strdup("$");
|
||||
else if (ft_strncmp(str, "$?", 2) == 0)
|
||||
key = ft_strdup("?");
|
||||
if (str[1] == '\0')
|
||||
key = ft_strdup("");
|
||||
else
|
||||
{
|
||||
i = 1;
|
||||
@ -42,6 +44,8 @@ static char *ft_getvalue(t_data *data, char *key)
|
||||
value = ft_itoa(data->exit_code);
|
||||
else if (ft_strcmp(key, "$") == 0)
|
||||
value = ft_strdup("PID");
|
||||
else if (key[0] == '\0')
|
||||
value = ft_strdup("$");
|
||||
else
|
||||
{
|
||||
value = get_value_by_key(key, data->env);
|
||||
@ -55,7 +59,8 @@ static char *ft_getvalue(t_data *data, char *key)
|
||||
return (value);
|
||||
}
|
||||
|
||||
static char *ft_getvalue_by_str(t_data *data, const char *str, size_t *key_len)
|
||||
static char *ft_getvalue_by_str(t_data *data, const char *str,
|
||||
size_t *key_len)
|
||||
{
|
||||
char *key;
|
||||
char *value;
|
||||
|
@ -115,10 +115,8 @@ int ft_cmds_parser(t_data *data, const char *line)
|
||||
}
|
||||
if (*data->cmds != NULL)
|
||||
{
|
||||
if (((t_cmd *) (*data->cmds)->content)->fd_in[0] == -1)
|
||||
((t_cmd *) (*data->cmds)->content)->fd_in[0] = 0;
|
||||
if (((t_cmd *) (ft_lstlast(*data->cmds))->content)->fd_out[0] == -1)
|
||||
(((t_cmd *) (ft_lstlast(*data->cmds))->content)->fd_out[0] = 1);
|
||||
ft_add_fd(((t_cmd *)(*data->cmds)->content)->fd_in, 0);
|
||||
ft_add_fd(((t_cmd *)(ft_lstlast(*data->cmds))->content)->fd_out, 1);
|
||||
}
|
||||
ft_freer_tab_ultimate(1, tab);
|
||||
return (0);
|
||||
|
@ -4,6 +4,6 @@
|
||||
# include "../cmd/cmd.h"
|
||||
|
||||
int ft_redirection(t_data *data, t_cmd *cmd, char *cmd_str);
|
||||
int *ft_get_heredoc();
|
||||
int *ft_get_heredoc(void);
|
||||
|
||||
#endif
|
||||
|
@ -32,5 +32,4 @@ char *ft_get_executable(t_data *data, const char *name);
|
||||
void ft_closer(int fds[2]);
|
||||
void ft_add_fd(int fds[2], int fd);
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user