Merge remote-tracking branch 'refs/remotes/origin/history_T_A' into history_T_A

This commit is contained in:
Arthur-gtr
2025-04-16 15:17:33 +02:00
3 changed files with 6 additions and 6 deletions

View File

@@ -80,7 +80,7 @@ char *his_last_same_command(char *line,
char *new_line = &line[his_variable->coord_variable + 1];
char *new_str = NULL;
for (int i = his_command->sz - 1; i >= 0; i--) {
for (int i = his_command->sz - 1; i > 0; i--) {
if (his_command[i].command == NULL) {
printf("%s: Event not found\n", new_line);
return NULL;
@@ -111,7 +111,7 @@ char *his_id_command(char *line,
}
new_line = concat_cmd_arg(his_command[id].command, his_command[id].arg);
new_str = cat_in_str(his_variable, line, new_line);
printf("%s\n", new_line);
printf("%s\n", new_str);
free(new_line);
free(line);
return new_str;
@@ -151,7 +151,7 @@ char *his_last_word(char *line,
if (!new_line)
return NULL;
new_str = cat_in_str(his_variable, line, new_line);
printf("%s\n", new_line);
printf("%s\n", new_str);
free(new_line);
free(line);
return new_str;

View File

@@ -14,7 +14,7 @@ int builtins_history(ef_t *ef, char **args __attribute__((unused)))
{
his_command_t *cmd_history = ef->builtin_handler->history_command;
for (int i = 0; i < cmd_history->sz; i++){
for (int i = 1; i < cmd_history->sz; i++){
if (cmd_history[i].arg) {
printf("%d %s %s\n", i, cmd_history[i].command,
cmd_history[i].arg);

View File

@@ -94,12 +94,12 @@ his_command_t *init_cmd_history(void)
if (cmd_history == NULL)
return NULL;
for (int i = 0; i != 100; i++){
for (int i = 1; i != 100; i++){
cmd_history[i].arg = NULL;
cmd_history[i].command = NULL;
cmd_history[i].id = i;
}
cmd_history->sz = 0;
cmd_history->sz = 1;
return cmd_history;
}