+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.
#include <stdlib.h>
#include <stdio.h>
+#include <sys/types.h>
+#include <sys/wait.h>
/* Licensed under the GPL
* Copyright (c) Miek Gieben, 2006
* 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
}
}
}
- close_pipes(pipes, argc);
-
- exit(EXIT_SUCCESS);
+ exit(close_pipes(pipes, argc));
}