diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/b_h.c | 4 | ||||
| -rw-r--r-- | src/e_builtins.c | 6 | ||||
| -rw-r--r-- | src/m_argv.c | 3 | 
3 files changed, 9 insertions, 4 deletions
@@ -20,7 +20,7 @@  #include "s_struct.h"  #include "u_utils.h" -static void		b_print_history(const char arg[], t_msh *msh) +static void		b_print_history(const char arg[], uint64_t max_hist, t_msh *msh)  {  	char		*prev_hist;  	char		*tok; @@ -35,7 +35,7 @@ static void		b_print_history(const char arg[], t_msh *msh)  		tok = ft_strtok(prev_hist, "\n");  		while (tok != NULL)  		{ -			ft_printf("%-5u  %s\n", i, tok); +			ft_printf("%5u  %s\n", i, tok);  			i++;  			tok = ft_strtok(NULL, "\n");  		} diff --git a/src/e_builtins.c b/src/e_builtins.c index 90e436e..92af2c3 100644 --- a/src/e_builtins.c +++ b/src/e_builtins.c @@ -51,7 +51,11 @@ static void  	if (ptr->env_fork != NULL)  		e_export_env_fork(ptr, msh);  	dup_redirs(ptr, msh); -	ret = msh->bu_ptr[bu_id](ptr->argv + 1, msh); +	ret = 0; +	if (bu_id == FT_ID_H && msh->fd == STDIN_FILENO) +		ret = msh->bu_ptr[bu_id](ptr->argv + 1, msh); +	else +		ret = msh->bu_ptr[bu_id](ptr->argv + 1, msh);  	u_eof_fd(msh->fd);  	s_com_destroy(&msh->com);  	s_line_clear(&msh->curr); diff --git a/src/m_argv.c b/src/m_argv.c index bdebd23..7661ef7 100644 --- a/src/m_argv.c +++ b/src/m_argv.c @@ -41,10 +41,11 @@ static char	*m_get_prev_hist(t_msh *msh)  		return (NULL);  	if (stat(histfile, &sb) == -1)  		return (NULL); -	if ((hist = (char*)malloc(sb.st_size * sizeof(char))) == NULL) +	if ((hist = (char*)malloc((sb.st_size + 1) * sizeof(char))) == NULL)  		return (NULL);  	if (read(fd, hist, sb.st_size) == -1)  		return (NULL); +	hist[sb.st_size] = C_NUL;  	return (hist);  }  | 
