Skip to content

Commit 30d0d54

Browse files
committed
Merge branch 'main' of https://github.com/EyobABN/simple_shell into main
Merging main with backup branches
2 parents c86faa2 + 3048231 commit 30d0d54

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

cdHandler.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ void updateEnv(char *key, char __attribute__((unused))**cmds, int *lst_ret)
3737
*/
3838
void cdHandler(char **av, char __attribute__((unused))**cmds, int *lst_ret)
3939
{
40+
int status;
41+
4042
if (*lst_ret != 0)
4143
{
4244
return;
@@ -48,13 +50,17 @@ void cdHandler(char **av, char __attribute__((unused))**cmds, int *lst_ret)
4850
{
4951
updateEnv("PWD", cmds, lst_ret);
5052
free_entire_arr(av);
53+
status = 0;
54+
*lst_ret = status;
5155
return;
5256
}
5357
}
5458
if (chdir(av[1]) == 0)
5559
{
5660
updateEnv("PWD", cmds, lst_ret);
5761
free_entire_arr(av);
62+
status = 0;
63+
*lst_ret = status;
5864
return;
5965
}
6066
else

setenvHandler.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ void setenvHandler(char **av, char __attribute__((unused))**cmds, int *lst_ret)
8888
environ[i] = new; /* needs to be free'd */
8989
break;
9090
}
91+
free(token);
9192
}
93+
free(token);
9294
if (found == 0)
9395
create_var(av, new);
9496
free_entire_arr(av);

0 commit comments

Comments
 (0)