From 265c467ad2841e2edacb0f7e8fed8525866574f5 Mon Sep 17 00:00:00 2001 From: drb23122 Date: Tue, 24 Mar 2026 12:50:26 +0000 Subject: [PATCH 1/2] alias overide stuff --- src/alias.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/alias.c b/src/alias.c index bdc527d..4dba388 100644 --- a/src/alias.c +++ b/src/alias.c @@ -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_a; a++) { + if (!strcmp(aliases[a]->name, tokens[1])) { + printf("Overriding alias %s\n", tokens[1]); + remove_alias(tokens); + break; + } + } + if (head_a >= ALIAS_LEN) { printf("Cannot add any more aliases!\n"); return 1; From 3db56557e84b461e84513dc84ffb35ed656c849e Mon Sep 17 00:00:00 2001 From: drb23122 Date: Tue, 24 Mar 2026 13:57:40 +0000 Subject: [PATCH 2/2] alias overide 2 --- src/alias.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/alias.c b/src/alias.c index da6d4a6..809f25e 100644 --- a/src/alias.c +++ b/src/alias.c @@ -125,7 +125,7 @@ int add_alias(char *tokens[INPUT_LEN]) { return 1; } - for (int a = 0; a < head_a; a++) { + 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); @@ -133,7 +133,7 @@ int add_alias(char *tokens[INPUT_LEN]) { } } - if (head_a >= ALIAS_LEN) { + if (head_alias >= ALIAS_LEN) { printf("Cannot add any more aliases!\n"); return 1; }