mahahahad / Minishell

1 stars 1 forks source link

feat: created the cd builtin #21

Closed Ali-Danish-72 closed 3 months ago

Ali-Danish-72 commented 3 months ago
It works almost exactly as the `bash` equivalent. If
no arguments are provided, it searches through the
list of environment variables to try and find the
the `HOME` variable and uses its value as the home
directory, resulting in the change being to that
directory specifically.

Invalid arguments and options are checked for and
throw an error. Both absolute and relative paths
are accepted by `chdir()`. There is no need to
expand on tilde [ ~ ] as `chdir()` handles it.

Previously, `ft_pwd()` was pushed with the message
that `ft_cd` must be functional to properly test the
output of `ft_pwd()`. I have tested that as well and
the function behaves as expected.
Ali-Danish-72 commented 3 months ago

I must also mention, currently below the main function in main.c, I have commented out the piece of code that I have used to test properly ft_cd and ft_pwd. Caution: the code is not independent, there are other changes made to make it work as well,