From a042114987129a32c7d7d3243a46e0dfd00b13b2 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sat, 30 Dec 2023 16:24:19 +0530 Subject: pass.c/cat: print newline if output is a terminal --- pass.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pass.c b/pass.c index e68a262..b66e2ac 100644 --- a/pass.c +++ b/pass.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -36,10 +37,15 @@ int cat(const char *path) const char *s = NULL; s = pass_cat(path); - if (s) + if (!s) + return -1; + + if(isatty(STDOUT_FILENO)) + puts(s); + else fputs(s, stdout); - return (s == NULL); + return 0; } int add(const char *path) -- cgit v1.2.3