echoctl et
This commit is contained in:
BIN
srcs/.lst_token.c.swp
Normal file
BIN
srcs/.lst_token.c.swp
Normal file
Binary file not shown.
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
|
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/04/24 10:49:07 by marde-vr ### ########.fr */
|
/* Updated: 2024/04/24 15:22:20 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -108,7 +108,6 @@ void end_execution(t_msh *msh, int cmd_count)
|
|||||||
free(msh->fds);
|
free(msh->fds);
|
||||||
signal(SIGINT, signal_handler_interactive);
|
signal(SIGINT, signal_handler_interactive);
|
||||||
signal(SIGQUIT, signal_handler_interactive);
|
signal(SIGQUIT, signal_handler_interactive);
|
||||||
set_echoctl(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void exec_commands(t_msh *msh)
|
void exec_commands(t_msh *msh)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/07 16:04:11 by tomoron #+# #+# */
|
/* Created: 2024/02/07 16:04:11 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/04/18 20:48:53 by marde-vr ### ########.fr */
|
/* Updated: 2024/04/24 15:17:53 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/06 20:46:19 by tomoron #+# #+# */
|
/* Created: 2024/02/06 20:46:19 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/04/18 20:48:56 by marde-vr ### ########.fr */
|
/* Updated: 2024/04/24 15:36:12 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ t_token *token_add_back(t_token *token, char *value)
|
|||||||
t_token *res;
|
t_token *res;
|
||||||
t_token *current;
|
t_token *current;
|
||||||
|
|
||||||
if (value && !*value)
|
if (/*value && !*value*/0)
|
||||||
{
|
{
|
||||||
free(value);
|
free(value);
|
||||||
return (token);
|
return (token);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
|
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/04/24 14:07:32 by tomoron ### ########.fr */
|
/* Updated: 2024/04/24 15:22:06 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -98,11 +98,8 @@ int init_minishell(t_msh **msh, int argc, char **argv, char **envp)
|
|||||||
(*msh)->env = get_env(envp);
|
(*msh)->env = get_env(envp);
|
||||||
(*msh)->env = add_shlvl((*msh)->env);
|
(*msh)->env = add_shlvl((*msh)->env);
|
||||||
tcgetattr(1, &t_p);
|
tcgetattr(1, &t_p);
|
||||||
(*msh)->echoctl = t_p.c_lflag & ECHOCTL;
|
|
||||||
signal(SIGINT, signal_handler_interactive);
|
signal(SIGINT, signal_handler_interactive);
|
||||||
signal(SIGQUIT, signal_handler_interactive);
|
signal(SIGQUIT, signal_handler_interactive);
|
||||||
if (set_echoctl(0))
|
|
||||||
ft_exit(*msh, 1);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
|
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/04/24 15:05:21 by tomoron ### ########.fr */
|
/* Updated: 2024/04/24 15:17:35 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -73,7 +73,6 @@ typedef struct s_msh
|
|||||||
int in_fd;
|
int in_fd;
|
||||||
int out_fd;
|
int out_fd;
|
||||||
int locked_return_code;
|
int locked_return_code;
|
||||||
int echoctl;
|
|
||||||
char *here_doc_filename;
|
char *here_doc_filename;
|
||||||
} t_msh;
|
} t_msh;
|
||||||
|
|
||||||
@ -149,7 +148,6 @@ char *get_var_name(char *str);
|
|||||||
int exec_builtin(t_msh *msh);
|
int exec_builtin(t_msh *msh);
|
||||||
void get_cmd_path(t_msh *msh);
|
void get_cmd_path(t_msh *msh);
|
||||||
int is_operand_type(t_cmd *cmd);
|
int is_operand_type(t_cmd *cmd);
|
||||||
int set_echoctl(int value);
|
|
||||||
int is_output_type(t_cmd *cmd);
|
int is_output_type(t_cmd *cmd);
|
||||||
int print_env(t_env *env);
|
int print_env(t_env *env);
|
||||||
t_cmd *free_cmd(t_cmd *cmd);
|
t_cmd *free_cmd(t_cmd *cmd);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/05 18:17:25 by marde-vr #+# #+# */
|
/* Created: 2024/03/05 18:17:25 by marde-vr #+# #+# */
|
||||||
/* Updated: 2024/04/24 10:42:16 by marde-vr ### ########.fr */
|
/* Updated: 2024/04/24 15:17:58 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -70,7 +70,6 @@ void execute_command(t_msh *msh, char **cmd_args)
|
|||||||
}
|
}
|
||||||
if (msh->tokens->value)
|
if (msh->tokens->value)
|
||||||
{
|
{
|
||||||
set_echoctl(msh->echoctl);
|
|
||||||
env = env_to_char_tab(msh->env);
|
env = env_to_char_tab(msh->env);
|
||||||
if (env)
|
if (env)
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/22 14:31:13 by tomoron #+# #+# */
|
/* Created: 2024/03/22 14:31:13 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/04/23 17:05:37 by tomoron ### ########.fr */
|
/* Updated: 2024/04/24 15:17:24 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -50,25 +50,6 @@ void signal_handler_here_doc(int signum)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_echoctl(int value)
|
|
||||||
{
|
|
||||||
struct termios t_p;
|
|
||||||
|
|
||||||
if (!isatty(1))
|
|
||||||
return (0);
|
|
||||||
if (tcgetattr(1, &t_p))
|
|
||||||
return (1);
|
|
||||||
if (((t_p.c_lflag & ECHOCTL) != 0) == value)
|
|
||||||
return (0);
|
|
||||||
if (value)
|
|
||||||
t_p.c_lflag = t_p.c_lflag | ECHOCTL;
|
|
||||||
else
|
|
||||||
t_p.c_lflag = t_p.c_lflag & (~ECHOCTL);
|
|
||||||
if (tcsetattr(1, TCSANOW, &t_p))
|
|
||||||
return (1);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void signal_handler_command(int signum)
|
void signal_handler_command(int signum)
|
||||||
{
|
{
|
||||||
(void)signum;
|
(void)signum;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/05 18:19:26 by marde-vr #+# #+# */
|
/* Created: 2024/03/05 18:19:26 by marde-vr #+# #+# */
|
||||||
/* Updated: 2024/04/24 10:51:28 by marde-vr ### ########.fr */
|
/* Updated: 2024/04/24 15:22:11 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
void ft_exit(t_msh *msh, int exit_code)
|
void ft_exit(t_msh *msh, int exit_code)
|
||||||
{
|
{
|
||||||
set_echoctl(msh->echoctl);
|
|
||||||
free_msh(msh);
|
free_msh(msh);
|
||||||
exit(exit_code);
|
exit(exit_code);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user