Tient Camille 0 bug whula

This commit is contained in:
Etienne Rey-bethbeder 2023-02-10 13:19:28 +01:00
parent 4f77dde859
commit 7b3389c75d
84 changed files with 132 additions and 88 deletions

Binary file not shown.

Binary file not shown.

77
env.c
View File

@ -6,17 +6,28 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */ /* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/02 14:39:56 by erey-bet #+# #+# */ /* Created: 2023/02/02 14:39:56 by erey-bet #+# #+# */
/* Updated: 2023/02/02 18:25:51 by erey-bet ### ########.fr */ /* Updated: 2023/02/03 16:04:16 by erey-bet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "env.h" #include "minishell.h"
#include "libftx/libftx.h"
int get_index(char *s, char c)
{
int i;
i = -1;
while (s[++i])
if (s[i] == c)
return (i);
return (-1);
}
void print_export(t_list **head, int fd) void print_export(t_list **head, int fd)
{ {
t_list *current; t_list *current;
char *ctn; char *ctn;
int v;
current = *head; current = *head;
while (current != NULL) while (current != NULL)
@ -24,9 +35,12 @@ void print_export(t_list **head, int fd)
ctn = current->content; ctn = current->content;
if (*(ft_strchr(ctn, '=') - 1) != '_') if (*(ft_strchr(ctn, '=') - 1) != '_')
{ {
v = get_index(ctn, '=');
write(fd, "declare -x ", 11); write(fd, "declare -x ", 11);
ft_putstr_fd(fd, ctn); write(fd, ctn, v + 1);
write(fd, "\n", 1); write(fd, "\"", 1);
ft_putstr_fd(ctn + v + 1, fd);
write(fd, "\"\n", 2);
} }
current = current->next; current = current->next;
} }
@ -39,7 +53,7 @@ void print_env(t_list **head, int fd)
current = *head; current = *head;
while (current != NULL) while (current != NULL)
{ {
ft_putstr_fd(fd, current->content); ft_putstr_fd(current->content, fd);
write(fd, "\n", 1); write(fd, "\n", 1);
current = current->next; current = current->next;
} }
@ -111,6 +125,50 @@ void add_sort(t_list **head, char *str)
} }
} }
char *get_value_index(int index, t_list **head)
{
t_list *current;
int i;
current = *head;
i = -1;
while (current != NULL && ++i != index)
current = current->next;
if (i == index)
return (ft_strchr(current->content, '=') + 1);
return (NULL);
}
int is_start(char *big, char *little)
{
int i;
i = 0;
while (big[i])
{
if (little[i] != big[i])
return (0);
i++;
if (!little[i])
return (1);
}
return (0);
}
char *get_value_key(char *key, t_list **head)
{
t_list *current;
current = *head;
while (current != NULL)
{
if (is_start(current->content, key))
return (ft_strchr(current->content, '=') + 1);
current = current->next;
}
return (NULL);
}
t_list **init_env(char **env) t_list **init_env(char **env)
{ {
t_list **head; t_list **head;
@ -122,11 +180,7 @@ t_list **init_env(char **env)
return (NULL); return (NULL);
i = -1; i = -1;
while (env[++i]) while (env[++i])
{
if (ft_strnstr(env[i], "XMODIFIERS=@im=ibus", 200))
write(1, "", 0);
add_sort(head, env[i]); add_sort(head, env[i]);
}
return (head); return (head);
} }
@ -134,6 +188,7 @@ t_list **init_env(char **env)
{ {
(void)argc; (void)argc;
(void)argv; (void)argv;
print_export(init_env(env)); ft_putstr_fd(get_value_index(10, init_env(env)), 1);
//print_env(init_env(env), 1);
return (0); return (0);
}*/ }*/

21
env.h
View File

@ -1,21 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* env.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/31 14:39:05 by erey-bet #+# #+# */
/* Updated: 2023/01/31 14:56:16 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ENV_H
# define ENV_H
typedef struct s_env {
void *ctn;
void *next;
} t_env;
#endif

BIN
env.o

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */ /* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
/* Updated: 2023/02/01 16:20:05 by cchauvet ### ########.fr */ /* Updated: 2023/02/03 12:34:10 by erey-bet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -67,7 +67,8 @@ char *ft_itoa(int n);
char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
void ft_striteri(char *s, void (*f)(unsigned int, char*)); void ft_striteri(char *s, void (*f)(unsigned int, char*));
void ft_putchar_fd(int fd, char c); void ft_putchar_fd(int fd, char c);
void ft_putstr_fd(int fd, char *s); void ft_putstr_fd(char *s, int fd);
void ft_putendl_fd(int fd, char *s); void ft_putendl_fd(int fd, char *s);
void ft_putnbr_fd(int fd, int n); void ft_putnbr_fd(int fd, int n);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -8,6 +8,9 @@
int ft_file_is_readable(char *path); int ft_file_is_readable(char *path);
int ft_file_is_writeable(char *path); int ft_file_is_writeable(char *path);
t_list **init_env(char **env);
char *get_value_index(int index, t_list **head);
char *get_value_key(char *key, t_list **head);
typedef struct cmd typedef struct cmd
{ {
@ -17,4 +20,9 @@ typedef struct cmd
char *args; char *args;
} cmd; } cmd;
typedef struct s_data
{
t_list **env;
} t_data;
#endif #endif

View File

@ -1,6 +1,6 @@
COLORTERM=truecolor COLORTERM=truecolor
DBUS_SESSION_BUS_ADDRESS='unix:path=/run/user/101231/bus,guid=2b19cb48c68a1a9a5df2465563da4d2b' DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/101231/bus,guid=621c3599211e51a4e50420bf63dcee5f
DBUS_STARTER_ADDRESS='unix:path=/run/user/101231/bus,guid=2b19cb48c68a1a9a5df2465563da4d2b' DBUS_STARTER_ADDRESS=unix:path=/run/user/101231/bus,guid=621c3599211e51a4e50420bf63dcee5f
DBUS_STARTER_BUS_TYPE=session DBUS_STARTER_BUS_TYPE=session
DESKTOP_SESSION=ubuntu DESKTOP_SESSION=ubuntu
DISPLAY=:0 DISPLAY=:0
@ -8,28 +8,28 @@ DOCKER_HOST=unix:///run/user/101231/docker.sock
GDMSESSION=ubuntu GDMSESSION=ubuntu
GDM_LANG=en GDM_LANG=en
GNOME_DESKTOP_SESSION_ID=this-is-deprecated GNOME_DESKTOP_SESSION_ID=this-is-deprecated
GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/dd4e2769_33dd_4e18_81b2_70c233dc78ce GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/277eb9d7_4a54_437b_9556_e8825e1c7429
GNOME_TERMINAL_SERVICE=:1.96 GNOME_TERMINAL_SERVICE=:1.89
GPG_AGENT_INFO=/run/user/101231/gnupg/S.gpg-agent:0:1 GPG_AGENT_INFO=/run/user/101231/gnupg/S.gpg-agent:0:1
GTK_MODULES=gail:atk-bridge GTK_MODULES=gail:atk-bridge
HOME=/nfs/homes/erey-bet HOME=/nfs/homes/erey-bet
IM_CONFIG_PHASE=1 IM_CONFIG_PHASE=1
INVOCATION_ID=4f6816c8fd9446809f7d454fd8bdc56a INVOCATION_ID=9d85372853b94435bbce5d2edac38c19
JOURNAL_STREAM=9:166232 JOURNAL_STREAM=9:2506910
KRB5CCNAME=FILE:/tmp/krb5cc_101231_TfpJ05 KRB5CCNAME=FILE:/tmp/krb5cc_101231_mfTZPs
LANG=en_US.UTF-8 LANG=en_US.UTF-8
LANGUAGE=en LANGUAGE=en
LOGNAME=erey-bet LOGNAME=erey-bet
MANAGERPID=38750 MANAGERPID=763384
OLDPWD=/nfs/homes/erey-bet/travaux/Cursus42/minishell OLDPWD=/nfs/homes/erey-bet/travaux/Cursus42/minishell
PATH=/nfs/homes/erey-bet/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin PATH=/nfs/homes/erey-bet/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PWD=/nfs/homes/erey-bet/travaux/Cursus42/minishell PWD=/nfs/homes/erey-bet/travaux/Cursus42/minishell
QT_ACCESSIBILITY=1 QT_ACCESSIBILITY=1
QT_IM_MODULE=ibus QT_IM_MODULE=ibus
SESSION_MANAGER=local/1C2.42angouleme.fr:@/tmp/.ICE-unix/39041,unix/1C2.42angouleme.fr:/tmp/.ICE-unix/39041 SESSION_MANAGER=local/1D2.42angouleme.fr:@/tmp/.ICE-unix/763641,unix/1D2.42angouleme.fr:/tmp/.ICE-unix/763641
SHELL=/bin/zsh SHELL=/bin/zsh
SHLVL=1 SHLVL=2
SSH_AGENT_PID=39003 SSH_AGENT_PID=763603
SSH_AUTH_SOCK=/run/user/101231/keyring/ssh SSH_AUTH_SOCK=/run/user/101231/keyring/ssh
TERM=xterm-256color TERM=xterm-256color
USER=erey-bet USER=erey-bet
@ -44,6 +44,7 @@ XDG_RUNTIME_DIR=/run/user/101231
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0 XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_CLASS=user XDG_SESSION_CLASS=user
XDG_SESSION_DESKTOP=ubuntu XDG_SESSION_DESKTOP=ubuntu
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0 XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session3
XDG_SESSION_TYPE=x11 XDG_SESSION_TYPE=x11
XMODIFIERS='@im=ibus' XMODIFIERS=@im=ibus
_=./minishell

View File

@ -1,50 +1,50 @@
SHELL=/bin/zsh
SESSION_MANAGER=local/1D2.42angouleme.fr:@/tmp/.ICE-unix/763641,unix/1D2.42angouleme.fr:/tmp/.ICE-unix/763641
QT_ACCESSIBILITY=1
COLORTERM=truecolor COLORTERM=truecolor
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/101231/bus,guid=2b19cb48c68a1a9a5df2465563da4d2b XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
DBUS_STARTER_ADDRESS=unix:path=/run/user/101231/bus,guid=2b19cb48c68a1a9a5df2465563da4d2b XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session3
DBUS_STARTER_BUS_TYPE=session XDG_MENU_PREFIX=gnome-
DESKTOP_SESSION=ubuntu
DISPLAY=:0
DOCKER_HOST=unix:///run/user/101231/docker.sock
GDMSESSION=ubuntu
GDM_LANG=en
GNOME_DESKTOP_SESSION_ID=this-is-deprecated GNOME_DESKTOP_SESSION_ID=this-is-deprecated
GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/dd4e2769_33dd_4e18_81b2_70c233dc78ce LANGUAGE=en
GNOME_TERMINAL_SERVICE=:1.96 SSH_AUTH_SOCK=/run/user/101231/keyring/ssh
GPG_AGENT_INFO=/run/user/101231/gnupg/S.gpg-agent:0:1 XMODIFIERS=@im=ibus
DESKTOP_SESSION=ubuntu
SSH_AGENT_PID=763603
GTK_MODULES=gail:atk-bridge GTK_MODULES=gail:atk-bridge
DBUS_STARTER_BUS_TYPE=session
KRB5CCNAME=FILE:/tmp/krb5cc_101231_mfTZPs
PWD=/nfs/homes/erey-bet/travaux/Cursus42/minishell
LOGNAME=erey-bet
XDG_SESSION_DESKTOP=ubuntu
XDG_SESSION_TYPE=x11
GPG_AGENT_INFO=/run/user/101231/gnupg/S.gpg-agent:0:1
XAUTHORITY=/nfs/homes/erey-bet/.Xauthority
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/erey-bet
GDM_LANG=en
HOME=/nfs/homes/erey-bet HOME=/nfs/homes/erey-bet
IM_CONFIG_PHASE=1 IM_CONFIG_PHASE=1
INVOCATION_ID=4f6816c8fd9446809f7d454fd8bdc56a
JOURNAL_STREAM=9:166232
KRB5CCNAME=FILE:/tmp/krb5cc_101231_TfpJ05
LANG=en_US.UTF-8 LANG=en_US.UTF-8
LANGUAGE=en XDG_CURRENT_DESKTOP=ubuntu:GNOME
LOGNAME=erey-bet VTE_VERSION=6003
MANAGERPID=38750 XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
OLDPWD=/nfs/homes/erey-bet/travaux/Cursus42/minishell GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/277eb9d7_4a54_437b_9556_e8825e1c7429
PATH=/nfs/homes/erey-bet/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin INVOCATION_ID=9d85372853b94435bbce5d2edac38c19
PWD=/nfs/homes/erey-bet/travaux/Cursus42/minishell MANAGERPID=763384
QT_ACCESSIBILITY=1 XDG_SESSION_CLASS=user
QT_IM_MODULE=ibus
SESSION_MANAGER=local/1C2.42angouleme.fr:@/tmp/.ICE-unix/39041,unix/1C2.42angouleme.fr:/tmp/.ICE-unix/39041
SHELL=/bin/zsh
SHLVL=1
SSH_AGENT_PID=39003
TERM=xterm-256color TERM=xterm-256color
USER=erey-bet USER=erey-bet
VTE_VERSION=6003 GNOME_TERMINAL_SERVICE=:1.89
XAUTHORITY=/nfs/homes/erey-bet/.Xauthority DISPLAY=:0
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg SHLVL=2
XDG_CURRENT_DESKTOP=ubuntu:GNOME QT_IM_MODULE=ibus
XDG_DATA_DIRS=/usr/share/gnome:/usr/share/ubuntu:/nfs/homes/erey-bet/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop DBUS_STARTER_ADDRESS=unix:path=/run/user/101231/bus,guid=621c3599211e51a4e50420bf63dcee5f
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/erey-bet
XDG_MENU_PREFIX=gnome-
XDG_RUNTIME_DIR=/run/user/101231 XDG_RUNTIME_DIR=/run/user/101231
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0 DOCKER_HOST=unix:///run/user/101231/docker.sock
XDG_SESSION_CLASS=user JOURNAL_STREAM=9:2506910
XDG_SESSION_DESKTOP=ubuntu XDG_DATA_DIRS=/usr/share/gnome:/usr/share/ubuntu:/nfs/homes/erey-bet/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0 PATH=/nfs/homes/erey-bet/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
XDG_SESSION_TYPE=x11 GDMSESSION=ubuntu
XMODIFIERS=@im=ibus DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/101231/bus,guid=621c3599211e51a4e50420bf63dcee5f
_=/nfs/homes/erey-bet/travaux/Cursus42/minishell/./minishell OLDPWD=/nfs/homes/erey-bet/travaux/Cursus42/minishell
SSH_AUTH_SOCK=/run/user/101231/keyring/ssh _=/usr/bin/env

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.