faboussard / 42_minishell

1 stars 0 forks source link

Fonction env #55

Closed melobern closed 6 months ago

melobern commented 6 months ago

En prévision du futur codage de cette fonction (et pour savoir si elle a besoin de savoir quels sont les arguments qui suivent : la réponse est oui), des tests sur la vraie fonction env.

-> Si plusieurs arguments, s'occupera du premier uniquement. -> Si c'est un dossier, mettra toujours "Permission denied" -> Si ce n'est pas un dossier ou qu'il n'existe pas, mettra toujours "No such file or directory"

mbernard@z3r8p3:~/sgoinfre/42_minishell.c$ env .
env: ‘..’: Permission denied
mbernard@z3r8p3:~/sgoinfre/42_minishell.c$ env ..
env: ‘..’: Permission denied
mbernard@z3r8p3:~/sgoinfre/42_minishell.c$ env ../../
env: ‘../../’: Permission denied
mbernard@z3r8p3:~/sgoinfre/42_minishell.c$ env ../../../
env: ‘../../../’: Permission denied
mbernard@z3r8p3:~/sgoinfre/42_minishell.c$ env libft/
env: ‘libft/’: Permission denied
mbernard@z3r8p3:~/sgoinfre/42_minishell.c$ env libft/ coucou
env: ‘libft/’: Permission denied
mbernard@z3r8p3:~/sgoinfre/42_minishell.c$ env includes/
env: ‘includes/’: Permission denied
mbernard@z3r8p3:~/sgoinfre/42_minishell.c$ env build/
env: ‘build/’: Permission denied
mbernard@z3r8p3:~/sgoinfre/42_minishell.c$ env coucou ca va
env: ‘coucou’: No such file or directory
mbernard@z3r8p3:~/sgoinfre/42_minishell.c$ env ca 
env: ‘ca’: No such file or directory
mbernard@z3r8p3:~/sgoinfre/42_minishell.c$ env va
env: ‘va’: No such file or directory
mbernard@z3r8p3:~/sgoinfre/42_minishell.c$ env Makefile 
env: ‘Makefile’: No such file or directory
mbernard@z3r8p3:~/sgoinfre/42_minishell.c$ ls
bash_2  CMakeLists.txt     includes  libft     minishell            non  questions  srcs  tests.txt
build   ignore_leaks.supp  info.txt  Makefile  minitester-minishell-tester  OUT  rour       test  ttet
mbernard@z3r8p3:~/sgoinfre/42_minishell.c$ env info.txt 
env: ‘info.txt’: No such file or directory
melobern commented 6 months ago

2eme point: si on enleve tout l env en faisant ënv -i ./minishell", il faut verifier que les variables suivantes seront bien print quand on fait env ou export :

mbernard@z3r8p3:~/sgoinfre/42_minishell.c$ env -i bash

mbernard@z3r8p3:/sgoinfre/mbernard/42_minishell.c$ env
PWD=/sgoinfre/mbernard/42_minishell.c
SHLVL=1
_=/usr/bin/env

mbernard@z3r8p3:/sgoinfre/mbernard/42_minishell.c$ export
declare -x OLDPWD
declare -x PWD="/sgoinfre/mbernard/42_minishell.c"
declare -x SHLVL="1"
mbernard@z3r8p3:/sgoinfre/mbernard/42_minishell.c$ 
faboussard commented 6 months ago

1er point le sujet demande de traiter env sans option ni argument.

2eme point ==> du coup on peut pas faire env -i ./minishell .

donc on cloooooose :D