mirror of
https://github.com/Savapitech/42sh.git
synced 2026-03-18 21:50:35 +01:00
Merge branch 'main' into Add-tilde
This commit is contained in:
@@ -42,9 +42,10 @@ typedef enum {
|
||||
T_ELSE = 1 << 19, // else
|
||||
T_ENDIF = 1 << 20, // endif
|
||||
T_TILDE = 1 << 21, // ~
|
||||
T_EOF = 1 << 22, // \0
|
||||
T_ARG = 1 << 23,
|
||||
T_INVALID = 1 << 24
|
||||
T_STAR = 1 << 22, // *
|
||||
T_EOF = 1 << 23, // \0
|
||||
T_ARG = 1 << 24,
|
||||
T_INVALID = 1 << 25
|
||||
} token_type_t;
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -20,8 +20,12 @@ ast_t *parse_arg(ast_ctx_t *ctx, ast_t *node)
|
||||
ctx->act_tok = get_next_token(ctx);
|
||||
if (ctx->act_tok.type == T_SEMICOLON)
|
||||
return node;
|
||||
if (*ctx->act_tok.str == '\\') {
|
||||
ctx->act_tok = get_next_token(ctx);
|
||||
ctx->act_tok.type = T_ARG;
|
||||
}
|
||||
if (ctx->act_tok.type & (T_ARG | T_REDIRECT | T_APPEND |
|
||||
T_IN_REDIRECT | T_HEREDOC | T_VAR)) {
|
||||
T_IN_REDIRECT | T_HEREDOC | T_VAR | T_STAR)) {
|
||||
if (!ensure_node_cap(node))
|
||||
return NULL;
|
||||
node->vector.tokens[node->vector.sz] = ctx->act_tok;
|
||||
|
||||
@@ -33,6 +33,8 @@ const tokens_list_t TOKENS_LIST[] = {
|
||||
{ T_THEN, "then", 4, "T_THEN"},
|
||||
{ T_ELSE, "else", 4, "T_ELSE"},
|
||||
{ T_ENDIF, "endif", 5, "T_ENDIF"},
|
||||
{ T_STAR, "*", 1, "T_STAR"},
|
||||
{ T_STAR, "~", 1, "T_TILDE"},
|
||||
{ T_EOF, "\0", 1, "T_EOF" }
|
||||
};
|
||||
|
||||
|
||||
@@ -48,7 +48,11 @@ bool process_args(ast_t *node, args_t *args, size_t *toks_i, ef_t *ef)
|
||||
{
|
||||
token_t tok = node->vector.tokens[*toks_i];
|
||||
|
||||
if (strcspn(tok.str, "*[]?") != strlen(tok.str))
|
||||
if (strchr(tok.str, '\\') != NULL) {
|
||||
args->args[args->sz] = tok.str;
|
||||
return true;
|
||||
}
|
||||
if (tok.type == T_STAR || strcspn(tok.str, "[]?") != strlen(tok.str))
|
||||
return (process_globbing(tok.str, args));
|
||||
if (!ensure_args_capacity(args))
|
||||
return false;
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
#include "debug.h"
|
||||
#include "env.h"
|
||||
#include "history.h"
|
||||
#include "local.h"
|
||||
#include "shell.h"
|
||||
#include "u_str.h"
|
||||
#include "local.h"
|
||||
#include "loop.h"
|
||||
|
||||
__attribute__((unused))
|
||||
static
|
||||
@@ -75,7 +74,7 @@ bool change_shell_command(char **buffer, exec_ctx_t *exec_ctx,
|
||||
free(tmp_buff);
|
||||
return false;
|
||||
}
|
||||
U_DEBUG("Buffer [%lu] [%s]\n", buffer_len, buffer);
|
||||
U_DEBUG("Buffer [%lu] [%s]\n", buffer_len, tmp_buff);
|
||||
visitor(tmp_buff, exec_ctx);
|
||||
free(tmp_buff);
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user