Skip to content

Commit

Permalink
Merge branch 'Dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
frouioui committed May 22, 2018
2 parents c3d30d2 + 783b077 commit 74fa81e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
8 changes: 7 additions & 1 deletion include/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <term.h>
#include "instruction.h"
#include "mylib.h"

Expand Down Expand Up @@ -48,6 +49,11 @@ typedef struct binding_s {
int suppr;
} binding_t;

typedef struct terminal_s {
struct termios old;
bool term;
} terminal_t;

typedef struct shell_s {
char **env;
char **paths;
Expand All @@ -56,8 +62,8 @@ typedef struct shell_s {
command_line_t *command_line;
binding_t *binding;
state_t state;
terminal_t terminal;
bool bonus;
bool term;
bool prompt;
} shell_t;

Expand Down
2 changes: 2 additions & 0 deletions src/destroy_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ int destroy_shell(shell_t *shell)
{
int code = shell->code;

if (shell->terminal.term == true)
tcsetattr(0, TCSANOW, &(shell->terminal.old));
destroy_backup(shell->backup);
free_array_string(shell->env);
free_array_string(shell->paths);
Expand Down
2 changes: 1 addition & 1 deletion src/initialisation_shell/initialisation_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static bool external_init(shell_t *shell)
{
shell->backup = initialisation_backup(shell->env);
shell->paths = init_paths(shell->env);
shell->term = init_terminal(shell);
shell->terminal.term = init_terminal(shell);
shell->binding = init_bindings(shell);
if (!shell->backup || !shell->paths)
return (false);
Expand Down
1 change: 1 addition & 0 deletions src/initialisation_shell/initialisation_terminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ bool init_terminal(shell_t *shell)

if (!isatty(0))
return (false);
tcgetattr(0, &shell->terminal.old);
if (get_term_caps(&new, shell->env) == 1)
return (false);
new.c_lflag &= ~(ICANON | ECHO);
Expand Down
2 changes: 1 addition & 1 deletion src/shell_loop/input/get_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ char *get_input(shell_t *shell, int fd_term, int fd_gnl)
{
char *input = NULL;

if (shell->term == false) {
if (shell->terminal.term == false) {
input = get_next_line(fd_gnl);
} else {
input = get_chars_from_term(shell, fd_term);
Expand Down

0 comments on commit 74fa81e

Please sign in to comment.