summaryrefslogtreecommitdiffstats
path: root/src/u_vars.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/u_vars.c')
-rw-r--r--src/u_vars.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/u_vars.c b/src/u_vars.c
index 28040b4..eafcace 100644
--- a/src/u_vars.c
+++ b/src/u_vars.c
@@ -54,16 +54,25 @@ static void
size_t dstsize,
t_msh *msh)
{
- char tmp[4];
+ char tmp[255];
+ int32_t n;
if (ft_strncmp(varname, FT_RET_VAR, 3) == 0)
{
ft_uitoa_s(tmp, msh->ret);
ft_strlcpy(str, tmp, 4);
}
- else if (ft_strncmp(varname, FT_ZER_VAR, 3) == 0)
+ else if (ft_strncmp(varname, FT_ARGC_VAR, 3) == 0)
{
- ft_strlcpy(str, msh->shname, dstsize);
+ ft_uitoa_s(tmp, msh->argc);
+ ft_strlcpy(str, tmp, 255);
+ }
+ else if (ft_strlen(varname) == 2 && ft_isdigit(*(varname + 1)) == TRUE)
+ {
+ if ((n = ft_atoi(varname + 1)) < msh->argc)
+ ft_strlcpy(str, msh->argv[n], dstsize);
+ else
+ (void)ft_memcpy(str, "", 1 * sizeof(char));
}
}