Ajout Pwd et dans le .h
This commit is contained in:
parent
afd71e5ed8
commit
8bd58675e9
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
|||||||
UTILS_SRC = utils/ft_is_in_quote.c utils/ft_strncpy.c utils/ft_strreplace.c utils/ft_strnchr.c utils/ft_split_quoted.c utils/ft_strshift.c utils/ft_quote_remover.c utils/ft_str_is_empty.c
|
UTILS_SRC = utils/ft_is_in_quote.c utils/ft_strncpy.c utils/ft_strreplace.c utils/ft_strnchr.c utils/ft_split_quoted.c utils/ft_strshift.c utils/ft_quote_remover.c utils/ft_str_is_empty.c
|
||||||
SRCS = ${UTILS_SRC} main.c file.c infile.c outfile.c heredoc.c syntatics.c cmd.c cmds.c env.c execution.c spacer.c env_fill.c
|
SRCS = ${UTILS_SRC} main.c file.c infile.c outfile.c heredoc.c syntatics.c cmd.c cmds.c env.c execution.c spacer.c env_fill.c echo.c pwd.c
|
||||||
|
|
||||||
OBJS = ${SRCS:.c=.o}
|
OBJS = ${SRCS:.c=.o}
|
||||||
|
|
||||||
|
5
echo.c
5
echo.c
@ -6,7 +6,7 @@
|
|||||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/17 13:09:08 by erey-bet #+# #+# */
|
/* Created: 2023/02/17 13:09:08 by erey-bet #+# #+# */
|
||||||
/* Updated: 2023/02/17 16:03:06 by erey-bet ### ########.fr */
|
/* Updated: 2023/02/17 16:53:04 by erey-bet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ int check_argument(char *str, int *check, int i)
|
|||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void echo(int fd, char *str)
|
int echo(int fd, char *str)
|
||||||
{
|
{
|
||||||
int check;
|
int check;
|
||||||
int i;
|
int i;
|
||||||
@ -59,4 +59,5 @@ void echo(int fd, char *str)
|
|||||||
ft_putchar_fd(fd, str[i++]);
|
ft_putchar_fd(fd, str[i++]);
|
||||||
if (!check)
|
if (!check)
|
||||||
write(fd, "\n", 1);
|
write(fd, "\n", 1);
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
17
minishell.h
17
minishell.h
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */
|
/* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/02/17 14:29:56 by cchauvet ### ########.fr */
|
/* Updated: 2023/02/17 16:52:41 by erey-bet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -22,9 +22,6 @@
|
|||||||
# include <readline/readline.h>
|
# include <readline/readline.h>
|
||||||
# include <readline/history.h>
|
# include <readline/history.h>
|
||||||
# define DEBUG 0
|
# define DEBUG 0
|
||||||
t_list **init_env(char **env);
|
|
||||||
int set_value_by_key(char *key, char *value, t_list **env);
|
|
||||||
char *get_value_by_key(char *key, t_list **head);
|
|
||||||
int ft_syntatic_verif(const char *str);
|
int ft_syntatic_verif(const char *str);
|
||||||
int ft_file_is_readable(const char *path);
|
int ft_file_is_readable(const char *path);
|
||||||
int ft_file_is_writable(const char *path);
|
int ft_file_is_writable(const char *path);
|
||||||
@ -44,6 +41,18 @@ char *ft_normalizer(char *str);
|
|||||||
char *ft_env_filler(t_list **env, const char *str);
|
char *ft_env_filler(t_list **env, const char *str);
|
||||||
char **env_to_strs(t_list **head);
|
char **env_to_strs(t_list **head);
|
||||||
|
|
||||||
|
/* Environnement */
|
||||||
|
t_list **init_env(char **env);
|
||||||
|
char **env_to_strs(t_list **head);
|
||||||
|
int create_value_by_key(char *key, char *value, t_list **head);
|
||||||
|
int set_value_by_key(char *key, char *value, t_list **head);
|
||||||
|
char *get_value_by_key(char *key, t_list **head);
|
||||||
|
|
||||||
|
/* Echo */
|
||||||
|
int echo(int fd, char *str);
|
||||||
|
/* PWD */
|
||||||
|
int pwd(t_list **env, int fd);
|
||||||
|
|
||||||
typedef struct s_cmd
|
typedef struct s_cmd
|
||||||
{
|
{
|
||||||
int fd_in;
|
int fd_in;
|
||||||
|
26
pwd.c
Normal file
26
pwd.c
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* pwd.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/02/17 16:09:11 by erey-bet #+# #+# */
|
||||||
|
/* Updated: 2023/02/17 16:53:36 by erey-bet ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
int pwd(t_list **env, int fd)
|
||||||
|
{
|
||||||
|
ft_putstr_fd(get_value_by_key("PWD", env), fd);
|
||||||
|
write(fd, "\n", 1);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[], char **env)
|
||||||
|
{
|
||||||
|
pwd(init_env(env), 1);
|
||||||
|
return (0);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user