multitudes / 42-minishell

This project is about creating a simple shell
MIT License
0 stars 0 forks source link

Correct assignment of history file string to path in function get_history_file_path() (file history.c) #37

Closed ProjektPhoenix closed 6 months ago

ProjektPhoenix commented 6 months ago

If ft_strjoin malloc and assignment to path from HOME environment variable fails, currently a direct assignment of path is done: path = "~/minihistfile"; There are a couple of issues with this:

  1. Should we assign a path at all if the previous assignment fails? -> What would be reasons for the assignments to fail? Is it just a failed malloc? If so should we continue program execution?
  2. The direct assignment of the string to path should not work or is in any case not conforming to 42 norm. Replace with path = ft_strdup("~/.minishell_history");
  3. This last allocation could of course also fail and failure would have to be interpreted again, coming back to the first issue above.
  4. If we do an assignment after the first ft_strjoin assignment fails, we should use the same path name as defined in the MINIHISTFILEPATH define
ProjektPhoenix commented 6 months ago

If we do another assignment, e.g. with ft_strdup(), the return value of path as handled in function add_to_hist_file() in same file should check if return value/path is NULL and act upon it.

multitudes commented 6 months ago

correct! will fix!