mirror of
https://github.com/zoriya/ash.git
synced 2026-05-31 01:55:56 +00:00
Handling ctrl d as eof
This commit is contained in:
@@ -31,6 +31,7 @@ SRC = src/shell.c \
|
||||
src/utility/get_return.c \
|
||||
src/key_bindings/basic_typing_functions.c \
|
||||
src/key_bindings/default_bindings.c \
|
||||
src/key_bindings/control_commands.c \
|
||||
src/redirections/pty_pipe.c
|
||||
|
||||
OBJ = $(SRC:%.c=%.o)
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "shell.h"
|
||||
|
||||
#define CTRL(c) ((c) & 0x1F)
|
||||
|
||||
typedef struct key_function
|
||||
{
|
||||
const char *name;
|
||||
@@ -25,4 +27,5 @@ extern const key_function_t key_functions[];
|
||||
extern const binding_t emacs_bindings[];
|
||||
|
||||
int self_insert_command(int key, buffer_t *buffer, env_t *env);
|
||||
int newline_command(int key, buffer_t *buffer, env_t *env);
|
||||
int newline_command(int key, buffer_t *buffer, env_t *env);
|
||||
int eof_command(int key, buffer_t *buffer, env_t *env);
|
||||
+1
-1
@@ -107,8 +107,8 @@ void run_cmd(char **argv, redirection *inout[2], env_t *env)
|
||||
path = eval(argv[0], argv, env);
|
||||
return (exec_error(path, argv[0]));
|
||||
}
|
||||
waitpid(pid, &status, 0);
|
||||
if (handle_parent_inout(inout, env, false))
|
||||
return;
|
||||
waitpid(pid, &status, 0);
|
||||
handle_signal(status, env);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2020
|
||||
** ash
|
||||
** File description:
|
||||
** control_commands
|
||||
*/
|
||||
|
||||
#include "shell.h"
|
||||
|
||||
int eof_command(int key, buffer_t *buffer, env_t *env)
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
@@ -13,10 +13,12 @@
|
||||
const key_function_t key_functions[] = {
|
||||
{"self-insert-command", &self_insert_command},
|
||||
{"newline", &newline_command},
|
||||
{"enf-of-file", &eof_command},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
const binding_t emacs_bindings[] = {
|
||||
{'\n', &newline_command},
|
||||
{CTRL('d'), &eof_command},
|
||||
{0, NULL}
|
||||
};
|
||||
@@ -84,8 +84,13 @@ void pty_get_output(redirection *pty, env_t *env)
|
||||
FILE *file = fdopen(pty->extra_data, "r");
|
||||
int y = getcury(env->window);
|
||||
|
||||
while (getline(&line, &size, file) > 0)
|
||||
mvaddstr(y++, 0, line);
|
||||
close(pty->fd);
|
||||
while (getline(&line, &size, file) > 0) {
|
||||
dprintf(2, "Writing at %d: %s\n", y, line);
|
||||
mvaddstr(y, 0, line);
|
||||
y++;
|
||||
}
|
||||
if (line)
|
||||
free(line);
|
||||
fclose(file);
|
||||
}
|
||||
Reference in New Issue
Block a user