void			builtin_command_exec_verbose(t_argparser_result *result,
													t_shenv *shenv)
{
	t_lst		*remainders_copy;
	char		*cmd_name;
	int			ret;

	remainders_copy = twl_lst_copy(result->remainders, NULL);
	ret = 1;
	while ((cmd_name = twl_lst_pop_front(remainders_copy)))
	{
		if (is_an_alias(cmd_name, shenv))
			ret = 0;
		else if (is_a_function(cmd_name, shenv))
			ret = 0;
		else if (is_a_builtin(cmd_name, shenv))
			ret = 0;
		else if (is_in_path(cmd_name, shenv))
			ret = 0;
	}
	twl_lst_del(remainders_copy, NULL);
	shenv->last_exit_code = ret;
}
示例#2
0
文件: tokenizer.c 项目: Delejnr/huo
struct Tokens * tokenize(struct String file, struct Tokens *content){
    assert(string_is_sane(&file));
    int counter = 0;
    while (counter < file.length){
        char c = file.body[counter];
        if(c != ' ' && c != '\n'){
            struct Token t = {
                .data = {
                    .length = 0,
                    .body = NULL
                }
            };
            assert(string_is_sane(&t.data));
            if(is_a_open_parens(c)){
                t.type = 'o';
            }
            else if(is_a_close_parens(c)){
                t.type = 'c';
            }
            else if(is_a_bracket(c)){
                t.type = 'b';
            }
            else if(is_a_end_bracket(c)){
                t.type = 'e';
            }
            else if(is_a_number(c)){
                t.type = 'n';
                while(is_a_number(c) || c == dot_const){
                    RESIZE(t.data.body, t.data.length+1);
                    t.data.body[t.data.length] = file.body[counter];
                    t.data.length++;
                    counter++;
                    c = file.body[counter];
                }
                RESIZE(t.data.body, t.data.length+1);
                t.data.body[t.data.length] = 0;
                assert(string_is_sane(&t.data));
                counter--;
            }
            else if(is_a_quote(c)){
                t.type = 's';
                counter++;
                char s = file.body[counter];
                while(!is_a_quote(s)){
                    RESIZE(t.data.body, t.data.length+1);
                    t.data.body[t.data.length] = file.body[counter];
                    t.data.length++;
                    counter++;
                    s = file.body[counter];
                }
                RESIZE(t.data.body, t.data.length+1);
                t.data.body[t.data.length] = 0;
                assert(string_is_sane(&t.data));
            }
            else if(is_a_function(c)){
                t.type = c;
            }
            else if(is_a_letter(c)){
                t.type = 'k';
                while(is_a_letter(c)){
                    RESIZE(t.data.body, t.data.length+1);
                    t.data.body[t.data.length] = file.body[counter];
                    t.data.length++;
                    counter++;
                    c = file.body[counter];
                }
                RESIZE(t.data.body, t.data.length+1);
                t.data.body[t.data.length] = 0;
                assert(string_is_sane(&t.data));
                counter--;
            }
            content->tokens[content->length] = t;
            content->length++;
        }
        counter++;
    }

    return content;
}