Esempio n. 1
0
File: sh_cmp.c Progetto: jalcim/42sh
int			cmp3(t_linez *linez, t_sh *term)
{
	if (!ft_strncmp("jobs", linez->ep_l, 4))
	{
		if (linez->ep_l[4])
			return (0);
		second_static(NULL, "print", NULL);
		return (1);
	}
	else if (!ft_strncmp("p-alias", linez->ep_l, 7))
		return (term->status = my_alias(NULL, -1));
	else if (!ft_strncmp("d-alias", linez->ep_l, 7))
		return (term->status = my_alias(&(linez->ep_l), -2));
	else if (!ft_strncmp("alias", linez->ep_l, 5))
	{
		if (!my_regex(linez->ep_l,
			"a\\l\\i\\a\\s\\ \\#a~zA~Z0~9-_\\=\\#a~zA~Z0~9-_", 0, '\0'))
		{
			my_alias(&(linez->ep_l), 4);
			return (term->status = 1);
		}
		ft_putendl_fd("Alias not well formated", 2);
		term->status = 0;
		return (1);
	}
	return (0);
}
Esempio n. 2
0
void		exec_cmd1(t_sh *t, int *i)
{
	char	*str;

	str = NULL;
	my_alias(&(t->args[0]), 1);	
	while (t->path[++*i])
	{
		t->tmp = ft_strjoin(t->path[*i], "/");
		if (access(str = ft_strjoin_free(t->tmp,
								t->args[0], 1), R_OK) > -1)
		{
			if ((t->fo = fork()) < 0)
			{
				ft_strdel(&str);
				ft_putstr_fd("fork error yeah\n", 2);
				exit(0);
			}
			if (!t->fo)
			{
				execve(str, t->args, t->env);
				exit(0);
			}
			break ;
		}
		ft_strdel(&(str));
	}
}
Esempio n. 3
0
void		child_process(char *s, char **tab, char **env)
{
  int		i;

  my_builtin(s, env);
  my_alias(s, tab, env);
  my_execution(tab, env);
  if (s[0] != 'c' || s[1] != 'd')
    {
      i = -1;
      while (env[++i])
      	free(env[i]);
      i = -1;
      while (tab[++i])
      	free(tab[i]);
      my_spec_error(s);
    }
  free(tab);
  free(env);
  exit(EXIT_SUCCESS);
}