Esempio n. 1
0
int	launch_options_process(char **path, char **env, char **av, int i)
{
  int	j;
  char	**tmp;
  char	*cmd_path;

  while (av[i] && my_find_in_str(av[i], '=') != -1)
    if ((env = set_env_option(av, env, &i)) == NULL)
      return (-1);
  if (!av[i])
    return (printenv_option(env));
  j = i;
  if ((tmp = cut_env_cmd(av, &i, &j)) == NULL)
    return (-1);
  if (!path || !(cmd_path = get_cmd_path(tmp[0], path)))
    return (0);
  my_free(tmp[0]);
  tmp[0] = cmd_path;
  env = launch_appropriate_cmd(tmp, env);
  if (!env)
    return (-1);
  if (env != NULL + 1)
    my_free_tab(env);
  return (0);
}
Esempio n. 2
0
int
external_command_exists(const char cmd[])
{
	char path[PATH_MAX];

	if(get_cmd_path(cmd, sizeof(path), path) == 0)
	{
		return executable_exists(path);
	}
	return 0;
}
Esempio n. 3
0
static void		manage_multi_cmd(t_lst *list, char **cmd)
{
	char **paths_tmp;
	char *cmd_path;

	cmd_path = NULL;
	paths_tmp = parse_path(list);
	cmd_path = get_cmd_path(cmd[3], paths_tmp);
	if (cmd_is_in_path(cmd[3], paths_tmp))
		do_fork(list, cmd + 3, cmd_path);
	else
	{
		ft_putstr_fd("env: ", 2);
		ft_putstr_fd(cmd[3], 2);
		ft_putendl_fd(": No such file or directory", 2);
	}
}