[FIX] decrease the size of the sttring pointer not the token list size

This commit is contained in:
tekClovis
2025-05-08 12:03:50 +02:00
parent 3c4e0f35ed
commit 581ca7bc7b
3 changed files with 13 additions and 13 deletions

View File

@@ -92,8 +92,8 @@ bool format_quotes(ast_t *node, char be_matched, size_t *i)
if (last_quote == NULL)
return (fprintf(stderr, "Unmatched \'%c\'.\n", be_matched), false);
node->vector.sz -= 2;
if (isblank(last_quote[1] || be_matched == '`')){
node->vector.tokens[*i].sz -= 2;
if (isblank(last_quote[1]) || be_matched == '`'){
last_quote[0] = '\0';
return true;
} else

View File

@@ -22,7 +22,6 @@ void exec_magic(ast_t *node, exec_ctx_t *ctx, size_t *i, int fd[2])
{
pid_t pid = 0;
node->vector.tokens[*i].str[node->vector.tokens[*i].sz - 1] = '\0';
pid = fork();
if (pid == 0){
close(fd[0]);

View File

@@ -189,19 +189,19 @@ TESTS = [
name="and or",
cmds=[
"ls&&ls\n",
"aa&&ls\n",
"aa&&aa\n",
"ls&&aa\n",
"bb&&ls\n",
"bb&&bb\n",
"ls&&bb\n",
"ls||ls\n",
"aa||ls\n",
"aa||aa\n",
"ls||aa\n",
"bb||ls\n",
"bb||bb\n",
"ls||bb\n",
"&&\n",
"ls && ls || ls && ls\n",
"ls && ls a || ls && ls\n",
"ls && ls || ls && ls a\n",
"ls && ls || ls && a\n",
"ls aa && ls || ls\n",
"ls && ls b || ls && ls\n",
"ls && ls || ls && ls b\n",
"ls && ls || ls && b\n",
"ls bb && ls || ls\n",
],
depends_on=()
),
@@ -213,6 +213,7 @@ TESTS = [
"echo `ls`\n",
"echo `ls\n",
"echo ls`\n",
"echo ls `ls`\n",
],
depends_on=()
),