예제 #1
0
int		ft_handle_cmdline(t_env *env_list)
{
	t_tree			**cmd_tree;
	int				i;

	if (g_main_line.cmd[0] == '{' || g_main_line.cmd[0] == '(')
		g_main_line.cmd = ft_parentheses();
	else
		g_main_line.cmd = ft_handle_quote();
	cmd_tree = ft_split_and_build();
	i = 0;
	while (cmd_tree[i])
	{
		ft_exec_tree(cmd_tree[i], env_list);
		i++;
	}
	return (0);
}
예제 #2
0
파일: quotes.c 프로젝트: nsavry/42sh
char		*ft_quote(char *line)
{
	char		*str;

	str = NULL;
	line = delete_spaces(line);
	if (line[ft_strlen(line) - 1] == '\\' &&
			((((int)ft_strlen(line) - 2) >= 0 &&
				line[ft_strlen(line) - 2] != '\\') || (ft_strlen(line) == 1)))
	{
		while (line[ft_strlen(line) - 1] == '\\' && ((ft_strlen(line) == 1) ||
						(((int)ft_strlen(line) - 2) >= 0 &&
									line[ft_strlen(line) - 2] != '\\')))
		{
			line = fn_delete(line, ft_strlen(line) - 1);
			str = ft_termcaps(ft_printf("> "));
			line = ft_strjoin(line, str);
		}
	}
	if (ft_strchr(line, '"') || ft_strchr(line, '\'') || ft_strchr(line, '`'))
		line = the_quotes(line);
	line = ft_parentheses(line, str);
	return (line);
}