Exemple #1
0
int			set_env_nothing(t_plist *plist, char **cmd)
{
  char			*new_env;

  new_env = NULL;
  if (check_env_nothing(plist, cmd) == -1)
    {
      new_env = my_strcat(new_env, cmd[1], -1, -1);
      new_env = my_strcat(new_env, "=", -1, -1);
      env_to_list(plist, new_env);
    }
  free(new_env);
  return (0);
}
Exemple #2
0
t_shell				*init(char **env)
{
	t_shell			*shell;

	if ((shell = shellnew()))
	{
		if ((shell->env = env_to_list(env)))
			shell->envc = list_to_tab(shell->env);
		if (!(shell->prompt = get_env(shell->env, "USER")))
			shell->prompt = ft_strdup("~>");
		return (shell);
	}
	return (shell);
}
Exemple #3
0
int			set_env(t_plist *plist, char **cmd, char **env)
{
  char			*new_env;

  (void)env;
  new_env = NULL;
  if (cmd[1] == NULL)
    {
      show_list(plist, NULL, NULL);
      return (0);
    }
  if (cmd[2] == NULL)
    return (set_env_nothing(plist, cmd));
  if (check_env(plist, cmd) == -1)
    {
      new_env = my_strcat(new_env, cmd[1], -1, -1);
      new_env = my_strcat(new_env, "=", -1, -1);
      new_env = my_strcat(new_env, cmd[2], -1, -1);
      env_to_list(plist, new_env);
    }
  free(new_env);
  return (0);
}