Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,24 @@ int add_alias(char *tokens[INPUT_LEN]) {
printf("Alias must have name and command!\n");
return 1;
}

// Checks if alias loaded from file is valid
if (!tokens[0]) {
return 1;
}
if (strcmp(tokens[0], "alias")) {
printf("Invalid alias from file!\n");
return 1;
}

for (int a = 0; a < head_alias; a++) {
if (!strcmp(aliases[a]->name, tokens[1])) {
printf("Overriding alias %s\n", tokens[1]);
remove_alias(tokens);
break;
}
}

if (head_alias >= ALIAS_LEN) {
printf("Cannot add any more aliases!\n");
return 1;
Expand Down