예제 #1
0
파일: exec_cmd.c 프로젝트: seblu/42sh
void			exec_cmd(s_cmd_node *cmd)
{
  assert(cmd);
  if (DEBUG_EXEC)
    cmd_debugger(cmd);
  //FIXME: expansions here
  if (!cmd->argv) {
    if (cmd->prefix) exec_prefix(cmd->prefix, 0);
    return;
  }
  if (func_exist(shell->func, cmd->argv[0]))
    exec_function(cmd->argv);
  else if (is_a_builtin(cmd->argv[0]))
    shell->status = get_builtin(cmd->argv[0])(cmd->argv);
  else
    shell->status = exec_program(cmd);
}
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;
}