Add alias test and change err output for history

This commit is contained in:
savalet
2025-04-29 22:13:27 +02:00
parent de7aac82c4
commit dd64525993
2 changed files with 14 additions and 4 deletions

View File

@@ -62,7 +62,7 @@ char *his_last_command(char *line,
char *new_str = NULL;
if (his_command->sz == 0){
printf("%d: Event not found\n", his_command->sz);
fprintf(stderr, "%d: Event not found.\n", his_command->sz);
return NULL;
}
new_line = concat_cmd_arg(his_command[his_command->sz - 1].command,
@@ -80,7 +80,7 @@ char *his_last_same_command(char *line,
for (int i = his_command->sz - 1; i > 0; i--) {
if (his_command[i].command == NULL) {
printf("%s: Event not found\n", new_line);
fprintf(stderr, "%s: Event not found.\n", new_line);
return new_str;
}
if (strncmp(his_command[i].command, new_line, strlen(new_line)) == 0) {
@@ -91,7 +91,7 @@ char *his_last_same_command(char *line,
return new_str;
}
}
printf("%s: Event not found\n", new_line);
fprintf(stderr, "%s: Event not found.\n", new_line);
return new_str;
}
@@ -103,7 +103,7 @@ char *his_id_command(char *line,
char *new_str = NULL;
if (id < 0 || id > 100 || his_command[id].command == NULL){
printf("%d: Event not found\n", id + 1);
fprintf(stderr, "%d: Event not found.\n", id + 1);
return new_str;
}
new_line = concat_cmd_arg(his_command[id].command, his_command[id].arg);

View File

@@ -172,4 +172,14 @@ TESTS = [
],
depends_on=("PIPE", "REDIR", "SEMICOLON",)
),
Test(
key="ALIAS",
name="alias",
cmds=[
"ll\nalias ll ls\nll\n",
"ll\n",
],
depends_on=()
),
]