Builtins fixed
The builtins wasnt protected, now all data received is protected, the hashmap addition is protected and added functionality of env, export and unset (not implemented in this version). Added fixed details documentation in docs/builtins_fixes.md generated by codex and created tests/builtins_edge_cases.sh to test all the builtins to work correctly
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
# include "minishell.h"
|
||||
# include "core.h"
|
||||
|
||||
typedef unsigned char (*t_builtin_func)(t_command cmd, t_minishell *minishell);
|
||||
typedef uint8_t (*t_builtin_func)(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Functions */
|
||||
@@ -25,24 +25,36 @@ typedef unsigned char (*t_builtin_func)(t_command cmd, t_minishell *minishell)
|
||||
|
||||
/* builtins.c */
|
||||
|
||||
extern u_int8_t set_builtins(t_minishell *minishell);
|
||||
extern uint8_t set_builtins(t_minishell *minishell);
|
||||
|
||||
extern u_int8_t is_builtin(const char *command_name, t_minishell *minishell);
|
||||
extern uint8_t is_builtin(const char *command_name, t_minishell *minishell);
|
||||
|
||||
/* cd.c */
|
||||
|
||||
extern u_int8_t builtin_cd(t_command cmd, t_minishell *minishell);
|
||||
extern uint8_t builtin_cd(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/* echo.c */
|
||||
|
||||
extern u_int8_t builtin_echo(t_command cmd, t_minishell *minishell);
|
||||
extern uint8_t builtin_echo(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/* exit.c */
|
||||
|
||||
extern u_int8_t builtin_exit(t_command cmd, t_minishell *minishell);
|
||||
extern uint8_t builtin_exit(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/* pwd.c */
|
||||
|
||||
extern u_int8_t builtin_pwd(t_command cmd, t_minishell *minishell);
|
||||
extern uint8_t builtin_pwd(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/* env.c */
|
||||
|
||||
extern uint8_t builtin_env(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/* export.c */
|
||||
|
||||
extern uint8_t builtin_export(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/* unset.c */
|
||||
|
||||
extern uint8_t builtin_unset(t_command cmd, t_minishell *minishell);
|
||||
|
||||
#endif /* BUILTINS_H */
|
||||
|
||||
@@ -107,4 +107,6 @@ extern void free_envp(char **envp);
|
||||
|
||||
extern char *get_env(const char *env_name, t_minishell *msh);
|
||||
|
||||
extern void unset_env(const char *env_name, t_minishell *msh);
|
||||
|
||||
#endif /* CORE_H */
|
||||
|
||||
Reference in New Issue
Block a user