Skip to content

Commit ef0f4e8

Browse files
committed
Pwd donee
1 parent 2dd0d46 commit ef0f4e8

File tree

5 files changed

+67
-9
lines changed

5 files changed

+67
-9
lines changed

.gitignore 2

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
### C ###
3+
# Prerequisites
4+
*.d
5+
6+
# Object files
7+
*.o
8+
*.ko
9+
*.obj
10+
*.elf
11+
12+
# Linker output
13+
*.ilk
14+
*.map
15+
*.exp
16+
17+
# Precompiled Headers
18+
*.gch
19+
*.pch
20+
21+
# Libraries
22+
*.a
23+
24+
# Shared objects (inc. Windows DLLs)
25+
*.dll
26+
*.so
27+
*.so.*
28+
*.dylib
29+
30+
# Executables
31+
*.exe
32+
*.out
33+
*.app
34+
*.i*86
35+
*.x86_64
36+
*.hex
37+
38+
# Debug files
39+
*.dSYM/
40+
*.su
41+
*.idb
42+
*.pdb
43+
44+
# Kernel Module Compile Results
45+
.idea/
46+
.DS_Store
47+
*.mod*
48+
*.cmd
49+
.tmp_versions/

aux.txt

-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
hola
2-
estoy en el campus 42
3-
adios

includes/minishell.h

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ void get_dir(void);
133133
void search_and_replace(t_list *head, const char *key,
134134
const char *new_value);
135135
void remove_quotes_in_array(char **str_array);
136+
void execute_pwd(void);
136137

137138
typedef struct pipex
138139
{

src/builtin.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
/* ::: :::::::: */
44
/* builtin.c :+: :+: :+: */
55
/* +:+ +:+ +:+ */
6-
/* By: alvalope <alvalope@student.42.fr> +#+ +:+ +#+ */
6+
/* By: ysingh <ysingh@student.42malaga.com> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2023/07/13 18:14:51 by alvalope #+# #+# */
9-
/* Updated: 2023/08/04 11:39:07 by alvalope ### ########.fr */
9+
/* Updated: 2023/08/04 15:29:37 by ysingh ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -98,3 +98,14 @@ void execute_cd(char **args)
9898
else
9999
ft_printf("Error: %s: %s\n", args[1], strerror(errno));
100100
}
101+
102+
void execute_pwd(void)
103+
{
104+
char *pwd;
105+
106+
pwd = ft_get_env("$PWD");
107+
if (pwd == NULL)
108+
ft_printf("Error: PWD not set\n");
109+
else
110+
ft_printf("%s\n", pwd);
111+
}

src/ft_do_commands2.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
/* ::: :::::::: */
44
/* ft_do_commands2.c :+: :+: :+: */
55
/* +:+ +:+ +:+ */
6-
/* By: alvalope <alvalope@student.42.fr> +#+ +:+ +#+ */
6+
/* By: ysingh <ysingh@student.42malaga.com> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2023/07/19 17:47:17 by alvalope #+# #+# */
9-
/* Updated: 2023/08/03 12:24:59 by alvalope ### ########.fr */
9+
/* Updated: 2023/08/04 15:29:37 by ysingh ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -33,8 +33,8 @@ void execute_builtin(char **cmd)
3333
execute_export(cmd);
3434
if (ft_strcmp(cmd[0], "cd") == 0)
3535
execute_cd(cmd);
36-
//if (ft_strcmp(cmd[0], "pwd") == 0)
37-
// execute_pwd(cmd);
36+
if (ft_strcmp(cmd[0], "pwd") == 0)
37+
execute_pwd();
3838
//if (ft_strcmp(cmd[0], "unset") == 0)
3939
// execute_unset(cmd);
4040
if (ft_strcmp(cmd[0], "exit") == 0)

0 commit comments

Comments
 (0)