diff options
author | sinanmohd <sinan@sinanmohd.com> | 2023-12-30 16:24:19 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2023-12-30 16:25:43 +0530 |
commit | a042114987129a32c7d7d3243a46e0dfd00b13b2 (patch) | |
tree | 8c92c4eb22627a4036e123db5f4f2c944a68bffa /pass.c | |
parent | dc1f4733c0c21c897dbcc430787d33dc0e6c6af3 (diff) |
pass.c/cat: print newline if output is a terminal
Diffstat (limited to 'pass.c')
-rw-r--r-- | pass.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1,4 +1,5 @@ #include <stdio.h> +#include <unistd.h> #include <string.h> #include <stdlib.h> #include <errno.h> @@ -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) |