mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-15 03:16:51 +01:00
「🎉」 init: Merged branch successfully
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/25 12:20:26 by adjoly #+# #+# */
|
||||
/* Updated: 2024/06/04 13:15:24 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/06/18 12:58:53 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
|
||||
# include "libft.h"
|
||||
# include "tokenizer.h"
|
||||
# include "env.h"
|
||||
|
||||
typedef struct s_cmd
|
||||
{
|
||||
@ -28,15 +29,19 @@ typedef enum s_quote
|
||||
{
|
||||
NOT_CLOSED = -1,
|
||||
FALSE,
|
||||
SINGLE,
|
||||
DOUBLE
|
||||
SINGLE = 39,
|
||||
DOUBLE = 34
|
||||
} t_quote;
|
||||
|
||||
void check_syntax(char *readline, char **argv);
|
||||
bool check_syntax(char *readline, char **argv);
|
||||
void send_error(char *msg, char **argv);
|
||||
void check_redir(t_list *redir, char **argv);
|
||||
t_cmd *get_redir_fd(void *content);
|
||||
t_list *get_cmd_list(t_list *list);
|
||||
t_cmd *get_redir_fd(void *content, t_env *env);
|
||||
t_list *get_cmd_list(t_list *list, t_env *env);
|
||||
char **split_argv(char *readline);
|
||||
char *env_var_replace(char *readline, t_env *env);
|
||||
size_t get_size_with_env(char *readline, t_env *env);
|
||||
size_t strlen_till_char(char *s, int c);
|
||||
/**
|
||||
* @brief Take the argv of a command a split the argv and the
|
||||
* command it self
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/03 19:35:01 by mmoussou #+# #+# */
|
||||
/* Updated: 2024/05/23 20:01:55 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/06/06 14:37:07 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/01 22:03:09 by mmoussou #+# #+# */
|
||||
/* Updated: 2023/11/11 13:19:18 by mmoussou ### ########.fr */
|
||||
/* Updated: 2024/06/10 17:13:04 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -23,5 +23,5 @@ int ft_strncmp(const char *s1, const char *s2, unsigned int n)
|
||||
return (((unsigned char *)s1)[i] - ((unsigned char *)s2)[i]);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
return (((unsigned char *)s1)[i] - ((unsigned char *)s2)[i]);
|
||||
}
|
||||
|
20
src/main.c
20
src/main.c
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
|
||||
/* Updated: 2024/06/04 21:42:55 by mmoussou ### ########.fr */
|
||||
/* Updated: 2024/06/20 14:00:59 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -87,18 +87,18 @@ int main(int ac, char **av, char **env)
|
||||
if (is_str(test, "exit"))
|
||||
break ;
|
||||
piped = tokenizer(test);
|
||||
check_redir(((t_token *)(piped->content))->redirection, av);
|
||||
cmd_list = get_cmd_list(piped);
|
||||
exec_split_cmd(cmd_list, &env_l);
|
||||
//check_redir(((t_token *)(piped->content))->redirection, av);
|
||||
cmd_list = get_cmd_list(piped, &env_l);
|
||||
//exec_split_cmd(cmd_list, &env_l);
|
||||
/*while (cmd_list)
|
||||
{
|
||||
cmd = cmd_list->content;
|
||||
cmd_list = cmd_list->next;
|
||||
}
|
||||
print_cmd(cmd);*/
|
||||
free(test);
|
||||
ft_lstclear(&piped, free_token);
|
||||
ft_free("a", &lll);
|
||||
}*/
|
||||
print_cmd(cmd_list->content);
|
||||
//free(test);
|
||||
//ft_lstclear(&piped, free_token);
|
||||
//ft_free("a", &lll);
|
||||
}
|
||||
ft_free("a", &lll);
|
||||
return (0);
|
||||
@ -110,6 +110,6 @@ int main(int ac, char **av, char **env)
|
||||
t_quote d;
|
||||
|
||||
d = is_inquote(ll, 6);
|
||||
ft_printf("%c\n", *(ll+6));
|
||||
ft_printf("%c\n", *(ll+6))
|
||||
print_quote_type(d);
|
||||
}*/
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/28 17:40:13 by adjoly #+# #+# */
|
||||
/* Updated: 2024/05/29 11:37:06 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/06/04 16:43:53 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -31,7 +31,24 @@ bool check_triple(char *chevron)
|
||||
return (false);
|
||||
}
|
||||
|
||||
void check_syntax(char *readline, char **argv)
|
||||
bool check_if_file(char *readline)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
tmp = readline;
|
||||
if (is_chevron(*tmp))
|
||||
{
|
||||
while (*tmp && is_chevron(*tmp))
|
||||
tmp++;
|
||||
while (*tmp && !ft_isalnum(*tmp))
|
||||
tmp++;
|
||||
if (!*tmp)
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
bool check_syntax(char *readline, char **argv)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
@ -39,7 +56,16 @@ void check_syntax(char *readline, char **argv)
|
||||
while (*tmp)
|
||||
{
|
||||
if (check_triple(tmp))
|
||||
{
|
||||
send_error(ERROR_SYNTAX, argv);
|
||||
return (true);
|
||||
}
|
||||
if (check_if_file(tmp))
|
||||
{
|
||||
send_error(ERROR_SYNTAX, argv);
|
||||
return (true);
|
||||
}
|
||||
tmp++;
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/28 18:09:49 by adjoly #+# #+# */
|
||||
/* Updated: 2024/05/28 18:15:09 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/06/04 15:39:24 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -16,5 +16,4 @@ void send_error(char *msg, char **argv)
|
||||
{
|
||||
ft_putstr_fd(argv[0], STDERR_FILENO);
|
||||
ft_putendl_fd(msg, STDERR_FILENO);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
62
src/parsing/env_var/env_var_replace.c
Normal file
62
src/parsing/env_var/env_var_replace.c
Normal file
@ -0,0 +1,62 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* env_var_replace.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/05 21:14:04 by adjoly #+# #+# */
|
||||
/* Updated: 2024/06/20 14:14:57 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "parsing.h"
|
||||
#include "env.h"
|
||||
|
||||
size_t strlen_till_notalnum(char *s)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
tmp = s;
|
||||
while (*tmp && ft_isalnum(*tmp))
|
||||
tmp++;
|
||||
return (tmp - s);
|
||||
}
|
||||
|
||||
char *env_var_replace(char *readline, t_env *env)
|
||||
{
|
||||
char *tmp;
|
||||
char *rl_dollared;
|
||||
size_t dollar_size;
|
||||
char *dollar;
|
||||
|
||||
rl_dollared = ft_calloc(get_size_with_env(readline, env) + 1, sizeof(char));
|
||||
if (rl_dollared == NULL)
|
||||
return (NULL);
|
||||
tmp = readline;
|
||||
while (*tmp)
|
||||
{
|
||||
if (*tmp == '$' && is_inquote(readline, tmp - readline) != SINGLE)
|
||||
{
|
||||
tmp++;
|
||||
dollar_size = strlen_till_notalnum(tmp);
|
||||
printf("%zu\n", dollar_size);
|
||||
dollar = env_getn_value(tmp, env, dollar_size - 1);
|
||||
if (!dollar)
|
||||
{
|
||||
tmp += dollar_size;
|
||||
continue ;
|
||||
}
|
||||
ft_strlcat(rl_dollared, dollar, ft_strlen(dollar) + ft_strlen(rl_dollared) + 1);
|
||||
tmp += dollar_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
ft_strlcat(rl_dollared, tmp, ft_strlen(rl_dollared) + 2);
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
return (rl_dollared);
|
||||
}
|
40
src/parsing/env_var/get_size_with_env.c
Normal file
40
src/parsing/env_var/get_size_with_env.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* get_size_with_env.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/06 15:01:19 by adjoly #+# #+# */
|
||||
/* Updated: 2024/06/10 17:11:16 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "env.h"
|
||||
#include "parsing.h"
|
||||
#include "libft.h"
|
||||
|
||||
size_t get_size_with_env(char *readline, t_env *env)
|
||||
{
|
||||
size_t size;
|
||||
char *tmp;
|
||||
char *dollar;
|
||||
|
||||
tmp = readline;
|
||||
size = ft_strlen(readline);
|
||||
while (*tmp)
|
||||
{
|
||||
if (*tmp == '$' && is_inquote(tmp, tmp - readline) != SINGLE && is_inquote(tmp, tmp - readline) != NOT_CLOSED)
|
||||
{
|
||||
tmp++;
|
||||
size -= strlen_till_char(tmp, ' ');
|
||||
dollar = env_getn_value(tmp, env, strlen_till_char(tmp, ' '));
|
||||
if (!dollar)
|
||||
continue ;
|
||||
size += ft_strlen(dollar);
|
||||
}
|
||||
tmp++;
|
||||
}
|
||||
return (size);
|
||||
}
|
29
src/parsing/env_var/strlen_till_char.c
Normal file
29
src/parsing/env_var/strlen_till_char.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* strlen_till_char.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/07 01:09:40 by adjoly #+# #+# */
|
||||
/* Updated: 2024/06/09 14:02:35 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
size_t strlen_till_char(char *s, int c)
|
||||
{
|
||||
char *tmp;
|
||||
size_t size;
|
||||
|
||||
tmp = s;
|
||||
size = 0;
|
||||
while (*tmp && *tmp != c)
|
||||
{
|
||||
tmp++;
|
||||
size++;
|
||||
}
|
||||
return (size);
|
||||
}
|
@ -6,14 +6,14 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/31 12:47:13 by adjoly #+# #+# */
|
||||
/* Updated: 2024/05/31 13:29:46 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/06/18 12:58:36 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include "parsing.h"
|
||||
|
||||
t_list *get_cmd_list(t_list *list)
|
||||
t_list *get_cmd_list(t_list *list, t_env *env)
|
||||
{
|
||||
t_list *tmp;
|
||||
t_list *cmd_list;
|
||||
@ -22,7 +22,7 @@ t_list *get_cmd_list(t_list *list)
|
||||
cmd_list = NULL;
|
||||
while (tmp)
|
||||
{
|
||||
ft_lstadd_back(&cmd_list, ft_lstnew(get_redir_fd(tmp->content)));
|
||||
ft_lstadd_back(&cmd_list, ft_lstnew(get_redir_fd(tmp->content, env)));
|
||||
tmp = tmp->next;
|
||||
}
|
||||
return (cmd_list);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/30 10:48:41 by adjoly #+# #+# */
|
||||
/* Updated: 2024/05/31 19:16:41 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/06/20 12:30:56 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,53 +14,62 @@
|
||||
#include "tokenizer.h"
|
||||
#include "execution.h"
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include "libft.h"
|
||||
|
||||
t_cmd *get_redir_fd(void *content)
|
||||
t_cmd *get_redir_fd(void *content, t_env *env)
|
||||
{
|
||||
t_token *token;
|
||||
t_list *tmp;
|
||||
t_redirection *tmp_redir;
|
||||
t_redirection out;
|
||||
t_redirection in;
|
||||
t_cmd *cmd;
|
||||
t_token *token;
|
||||
t_list *tmp;
|
||||
t_redirection *tmp_redir;
|
||||
t_redirection_sign out;
|
||||
t_redirection_sign in;
|
||||
t_cmd *cmd;
|
||||
|
||||
token = (t_token *)content;
|
||||
tmp = token->redirection;
|
||||
cmd = NULL;
|
||||
out.sign = INFILE;
|
||||
in.sign = OUTFILE;
|
||||
out = INFILE;
|
||||
in = OUTFILE;
|
||||
cmd = ft_calloc(sizeof(t_cmd), 1);
|
||||
while (tmp)
|
||||
{
|
||||
tmp_redir = (t_redirection *)tmp->content;
|
||||
if (tmp_redir->sign == (t_redirection_sign)HEREDOC)
|
||||
{
|
||||
in.file_name = NULL;
|
||||
in.sign = HEREDOC;
|
||||
close(cmd->infile);
|
||||
if (cmd->infile != 0)
|
||||
close(cmd->infile);
|
||||
in = HEREDOC;
|
||||
cmd->infile = ft_heredoc(tmp_redir->file_name);
|
||||
}
|
||||
else if (tmp_redir->sign == INFILE)
|
||||
{
|
||||
in.sign = INFILE;
|
||||
in.file_name = tmp_redir->file_name;
|
||||
if (cmd->infile != 0)
|
||||
close(cmd->infile);
|
||||
cmd->infile = open(tmp_redir->file_name, O_RDONLY);
|
||||
in = INFILE;
|
||||
}
|
||||
else if (tmp_redir->sign == OUTFILE)
|
||||
{
|
||||
if (cmd->infile != 0)
|
||||
close(cmd->outfile);
|
||||
out = OUTFILE;
|
||||
cmd->outfile = open(tmp_redir->file_name, O_CREAT | O_TRUNC | O_WRONLY, 0644);
|
||||
}
|
||||
else if (tmp_redir->sign == OUT_APPEND)
|
||||
{
|
||||
if (cmd->infile != 0)
|
||||
close(cmd->outfile);
|
||||
out = OUT_APPEND;
|
||||
cmd->outfile = open(tmp_redir->file_name, O_CREAT | O_APPEND | O_WRONLY, 0644);
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
if (in.sign == OUTFILE)
|
||||
if (in == OUTFILE)
|
||||
cmd->infile = STDIN_FILENO;
|
||||
else if (in.sign == INFILE)
|
||||
{
|
||||
cmd->infile = open(in.file_name, O_RDONLY);
|
||||
ft_putendl_fd(in.file_name, STDOUT_FILENO);
|
||||
}
|
||||
if (out.sign == INFILE)
|
||||
if (out == INFILE)
|
||||
cmd->outfile = STDOUT_FILENO;
|
||||
cmd = split_cmd(token->argv, cmd);
|
||||
char *ll = env_var_replace(token->argv, env);
|
||||
cmd = split_cmd(ll, cmd);
|
||||
return (cmd);
|
||||
}
|
||||
|
@ -6,18 +6,19 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/20 20:06:13 by adjoly #+# #+# */
|
||||
/* Updated: 2024/05/21 20:34:14 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/06/20 11:07:56 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "parsing.h"
|
||||
#include "libft.h"
|
||||
#include <stdio.h>
|
||||
|
||||
t_quote __is_quote(char c)
|
||||
{
|
||||
if (c == 39)
|
||||
if (c == SINGLE)
|
||||
return (SINGLE);
|
||||
if (c == 34)
|
||||
if (c == DOUBLE)
|
||||
return (DOUBLE);
|
||||
return (FALSE);
|
||||
}
|
||||
@ -27,12 +28,8 @@ char *search_for_next_quote(char *s, t_quote quote_type)
|
||||
char *tmp;
|
||||
|
||||
tmp = s;
|
||||
while (*tmp)
|
||||
{
|
||||
if (__is_quote(*tmp) == quote_type)
|
||||
break ;
|
||||
while (*tmp && __is_quote(*tmp) != quote_type)
|
||||
tmp++;
|
||||
}
|
||||
return (tmp);
|
||||
}
|
||||
|
||||
@ -43,19 +40,20 @@ t_quote is_inquote(char *s, size_t i)
|
||||
t_quote quote_type;
|
||||
|
||||
start_quote = 0;
|
||||
printf("%zu", i);
|
||||
tmp = s;
|
||||
quote_type = FALSE;
|
||||
while (*tmp)
|
||||
{
|
||||
if ((size_t)(tmp - s) > i)
|
||||
if ((size_t)(tmp - s + 1) > i)
|
||||
break ;
|
||||
if (__is_quote(*tmp) != FALSE)
|
||||
{
|
||||
start_quote = tmp - s;
|
||||
quote_type = __is_quote(*tmp);
|
||||
tmp = search_for_next_quote(tmp, quote_type);
|
||||
tmp++;
|
||||
if (*tmp && (start_quote < i && (size_t)(tmp - s) > i))
|
||||
tmp = search_for_next_quote(tmp, quote_type);
|
||||
if ((start_quote < i && (size_t)(tmp - s) > i))
|
||||
return (quote_type);
|
||||
else if (!*tmp)
|
||||
return (NOT_CLOSED);
|
||||
|
57
src/parsing/split_argv.c
Normal file
57
src/parsing/split_argv.c
Normal file
@ -0,0 +1,57 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* split_argv.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/05 13:48:57 by adjoly #+# #+# */
|
||||
/* Updated: 2024/06/10 16:29:12 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include "parsing.h"
|
||||
|
||||
/*char *end_of_arg(char *readline)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
tmp = readline;
|
||||
while (*tmp)
|
||||
{
|
||||
if (*tmp == 32 && is_inquote(readline, tmp - readline))
|
||||
break ;
|
||||
tmp++;
|
||||
}
|
||||
return (tmp);
|
||||
}
|
||||
|
||||
size_t count_args(char *readline)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
tmp = readline;
|
||||
while (*tmp)
|
||||
{
|
||||
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
|
||||
char **split_argv(char *readline)
|
||||
{
|
||||
char *tmp;
|
||||
char **argv;
|
||||
|
||||
tmp = readline;
|
||||
ft_putnbr_fd(count_args(readline), STDOUT_FILENO);
|
||||
argv = ft_calloc(count_args(readline), sizof(char *));
|
||||
while (*tmp)
|
||||
{
|
||||
|
||||
tmp++;
|
||||
}
|
||||
return (argv);
|
||||
}
|
||||
*/
|
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/04 15:00:32 by adjoly #+# #+# */
|
||||
/* Updated: 2024/06/08 18:31:42 by mmoussou ### ########.fr */
|
||||
/* Updated: 2024/06/18 12:56:43 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/02 14:42:00 by adjoly #+# #+# */
|
||||
/* Updated: 2024/05/27 19:00:47 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/06/11 16:04:42 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -25,7 +25,7 @@ char *get_pwd(t_env env)
|
||||
home = env_get_value("HOME", &env);//getenv("HOME");
|
||||
if (!pwd)
|
||||
return (NULL);
|
||||
if (!ft_strncmp(pwd, home, ft_strlen(home)))
|
||||
if (!ft_strncmp(pwd, home, ft_strlen(home) - 1))
|
||||
{
|
||||
pwd += ft_strlen(home);
|
||||
pwd = ft_strjoin("~", pwd);
|
||||
|
Reference in New Issue
Block a user