diff --git a/peek/peek.c b/peek/peek.c index fca5335..18eb997 100644 --- a/peek/peek.c +++ b/peek/peek.c @@ -1,5 +1,5 @@ #include /* errno */ -#include /* fprintf(3), getc(3), putc(3), EOF */ +#include /* fprintf(3), getc(3), putc(3), EOF, NULL */ #include /* size_t */ #include /* strerror(3) */ #if !defined EX_OK || !defined EX_OSERR || !defined EX_USAGE @@ -37,11 +37,9 @@ int main(int argc, char *argv[]){ case 'o': outputs[0] = STDOUT_FILENO; break; case 'e': outputs[1] = STDERR_FILENO; break; case 'p': - if(pipe(p) != 0){ - fprintf(stderr, "%s: %s\n", - argv[0], strerror(errno)); - return EX_OSERR; - }else + if(pipe(p) != 0) + goto die; + else outputs[2] = p[1]; break; default: goto usage; @@ -87,5 +85,5 @@ usage: fprintf(stderr, "Usage: %s (-1eno)" return EX_OK; die: fprintf(stderr, "%s: %s\n", argv[0], strerror(errno)); - return EX_USAGE; + return EX_OSERR; }