summaryrefslogtreecommitdiffstats
path: root/src/p_redirs.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-10-22 17:01:34 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-10-22 17:01:34 +0200
commit03c2b479292928babd8249c28c76367fdb74b02e (patch)
tree05353f64cf98991fb91b8cc9854aa6008624707f /src/p_redirs.c
parentIn progress + norme (diff)
download42-minishell-03c2b479292928babd8249c28c76367fdb74b02e.tar.gz
42-minishell-03c2b479292928babd8249c28c76367fdb74b02e.tar.bz2
42-minishell-03c2b479292928babd8249c28c76367fdb74b02e.tar.xz
42-minishell-03c2b479292928babd8249c28c76367fdb74b02e.tar.zst
42-minishell-03c2b479292928babd8249c28c76367fdb74b02e.zip
Ternary is cool
Diffstat (limited to 'src/p_redirs.c')
-rw-r--r--src/p_redirs.c6
1 files changed, 2 insertions, 4 deletions
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];