From 03c2b479292928babd8249c28c76367fdb74b02e Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 22 Oct 2020 17:01:34 +0200 Subject: Ternary is cool --- src/p_redirs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/p_redirs.c b/src/p_redirs.c index 091293c..a47812c 100644 --- a/src/p_redirs.c +++ b/src/p_redirs.c @@ -121,10 +121,8 @@ static void p_get_redir(char word[], char *ptr, t_com *com, t_msh *msh) fd_rdr[RDR] = (fd_rdr[RDR] == 1 && *(ptr + 1) == '>') ? (2) : (fd_rdr[1]); fd_rdr[RDR] = (fd_rdr[RDR] == -1 && *(ptr + 1) == '<') ? (-2) : (fd_rdr[1]); fd_rdr[RDR] = (fd_rdr[RDR] == -2 && *(ptr + 2) == '-') ? (-3) : (fd_rdr[1]); - if (fd_rdr[FD] == STDOUT_FILENO) - pos[0] = (ptr - word); - else - pos[0] = (ptr - word) - ft_intlen(fd_rdr[FD]); + pos[0] = (fd_rdr[FD] == STDOUT_FILENO) ? + (ptr - word) : ((ptr - word) - ft_intlen(fd_rdr[FD])); tmp.word = word; tmp.ptr = ptr; tmp.redir = fd_rdr[RDR]; -- cgit v1.2.3