fix: removed temp main

This commit is contained in:
william.valenduc 2026-01-09 16:17:38 +00:00
parent e8d6ac902c
commit 2f2cdda801

View file

@ -6,6 +6,14 @@
#include "../ast/ast.h" #include "../ast/ast.h"
// static size_t var_len(char *start)
// {
// char *iter = start;
// while (*iter != ' ' && *iter != 0)
// *iter++;
// return iter - start;
// }
struct ast_cmd *expand(struct ast_cmd *cmd) struct ast_cmd *expand(struct ast_cmd *cmd)
{ {
if (cmd == NULL) if (cmd == NULL)
@ -33,11 +41,14 @@ struct ast_cmd *expand(struct ast_cmd *cmd)
in_quotes = !in_quotes; in_quotes = !in_quotes;
memmove(&str[i], &str[i + 1], strlen(&str[i + 1]) + 1); memmove(&str[i], &str[i + 1], strlen(&str[i + 1]) + 1);
} }
// else if (str[i] == '$' && str[i + 1] != '\0' && str[i + 1] != '$' else if (str[i] == '$' && str[i + 1] != 0 && !isspace(str[i + 1]))
// && str[i + 1] != ' ')
else if (str[i] == '$' && isalnum(str[i + 1]))
{ {
// variable expansion // size_t len = var_len(str + i + 1);
// char *end = str + i + len + 1;
// char c = *end;
// *end = 0;
// printf("var: %s\n", str + i + 1);
// *end = c;
} }
} }
@ -61,8 +72,16 @@ struct ast_cmd *expand(struct ast_cmd *cmd)
return cmd; return cmd;
} }
int main() // int main()
{ // {
printf("Expansion module test\n"); // printf("Expansion module test\n");
return 0; // struct ast_cmd ast_cmd;
} // // char str[] = "echo Hello $?";
// char str[] = "echo Hello $AE86";
// ast_cmd.cmd = list_append(NULL, str);
// struct ast_cmd *cmd2 = expand(&ast_cmd);
// printf("cmd2: %s\n", (char *)cmd2->cmd->data);
// return 0;
// }