diff options
author | Joey Hess <joey@kitenet.net> | 2011-02-19 17:35:32 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-02-19 17:35:32 -0400 |
commit | 6827d8ff8e7c4e2003c6065d1769c780b4f96973 (patch) | |
tree | 75122abb9937e20845a8500e185d55f6cf8f0b0b | |
parent | da4a447c4fda5972cd486c3d6e342476429b2733 (diff) | |
download | moreutils-6827d8ff8e7c4e2003c6065d1769c780b4f96973.tar.gz |
pee: Propigate exit status of commands run.
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | pee.c | 19 |
2 files changed, 19 insertions, 6 deletions
diff --git a/debian/changelog b/debian/changelog index 6d41dff..66f923c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +moreutils (0.44) UNRELEASED; urgency=low + + * pee: Propigate exit status of commands run. + + -- Joey Hess <joeyh@debian.org> Sat, 19 Feb 2011 17:34:50 -0400 + moreutils (0.43) unstable; urgency=low * chronic: New command, runs a command quietly, unless it fails. @@ -1,5 +1,7 @@ #include <stdlib.h> #include <stdio.h> +#include <sys/types.h> +#include <sys/wait.h> /* Licensed under the GPL * Copyright (c) Miek Gieben, 2006 @@ -9,12 +11,19 @@ * pipes _and_ output to standard output */ -void +int close_pipes(FILE **p, size_t i) { + int ret=EXIT_SUCCESS; size_t j; - for (j = 0; j < i; j++) - pclose(p[j]); + for (j = 0; j < i; j++) { + int r = pclose(p[j]); + if (WIFEXITED(r)) + ret |= WEXITSTATUS(r); + else + ret |= 1; + } + return ret; } int @@ -48,7 +57,5 @@ main(int argc, char **argv) { } } } - close_pipes(pipes, argc); - - exit(EXIT_SUCCESS); + exit(close_pipes(pipes, argc)); } |