feat(vars): $# init

This commit is contained in:
william.valenduc 2026-01-24 14:51:27 +00:00
parent da948f58fe
commit 07d345f754
2 changed files with 3 additions and 4 deletions

View file

@ -67,6 +67,9 @@ int args_handler(int argc, char **argv, struct args_options *options,
} }
} }
int_to_str(arg_index - 1, index_str);
set_var_copy(vars, "#", index_str);
if (options->type == INPUT_UNDEFINED) if (options->type == INPUT_UNDEFINED)
options->type = INPUT_STDIN; options->type = INPUT_STDIN;

View file

@ -245,8 +245,6 @@ Test(expand, pid)
struct ast_command *ast_command = ast_get_command(ast); struct ast_command *ast_command = ast_get_command(ast);
struct hash_map *vars = vars_init(); struct hash_map *vars = vars_init();
vars_default(vars);
struct ast_command *command2 = expand(ast_command, vars); struct ast_command *command2 = expand(ast_command, vars);
cr_assert_not_null(command2, "Expansion returned NULL"); cr_assert_not_null(command2, "Expansion returned NULL");
int pid = atoi((char *)command2->command->data); int pid = atoi((char *)command2->command->data);
@ -265,8 +263,6 @@ Test(expand, default_last_exit_code)
struct ast_command *ast_command = ast_get_command(ast); struct ast_command *ast_command = ast_get_command(ast);
struct hash_map *vars = vars_init(); struct hash_map *vars = vars_init();
vars_default(vars);
struct ast_command *command2 = expand(ast_command, vars); struct ast_command *command2 = expand(ast_command, vars);
cr_assert_not_null(command2, "Expansion returned NULL"); cr_assert_not_null(command2, "Expansion returned NULL");
int code = atoi((char *)command2->command->data); int code = atoi((char *)command2->command->data);