Skip to content

Commit

Permalink
implement -A optional flag to return all exit codes on stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
sebalos314 committed Sep 6, 2017
1 parent 79aa5a4 commit d1a5247
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
3 changes: 3 additions & 0 deletions doc/pdsh.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ character.
.I "-S"
Return the largest of the remote command return values.
.TP
.I "-A"
Return all individual exit codes
.TP
.I "-h"
Output usage menu and quit. A list of available rcmd modules
will also be printed at the end of the usage message.
Expand Down
6 changes: 5 additions & 1 deletion src/common/pipecmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ int pipecmd_wait (pipecmd_t p, int *pstatus)
err ("%p: %S: %s pid %ld: waitpid: %m\n", p->target,
xbasename (p->path), p->pid);

if (status != 0)
if (rc_all_display)
out ("%p: %S: %s exited with exit code %d\n",
p->target, xbasename (p->path), WEXITSTATUS (status));

else if (status != 0)
err ("%p: %S: %s exited with exit code %d\n",
p->target, xbasename (p->path), WEXITSTATUS (status));

Expand Down
13 changes: 10 additions & 3 deletions src/pdsh/opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@

#define OPT_USAGE_DSH "\
Usage: pdsh [-options] command ...\n\
-S return largest of remote command return values\n"
-S return largest of remote command return values\n\
-A return all exit codes on stdout\n"


/* -s option only useful on AIX */
#if HAVE_MAGIC_RSHELL_CLEANUP
Expand Down Expand Up @@ -113,9 +115,9 @@ Usage: rpdcp [-options] src [src2...] dir\n\
/* undocumented "-K" option - keep domain name in output */

#if HAVE_MAGIC_RSHELL_CLEANUP
#define DSH_ARGS "sS"
#define DSH_ARGS "sSA"
#else
#define DSH_ARGS "S"
#define DSH_ARGS "SA"
#endif
#define PCP_ARGS "pryzZe:"
#define GEN_ARGS "hLNKR:M:t:cqf:w:x:l:u:bI:dVT:Q"
Expand Down Expand Up @@ -419,6 +421,8 @@ void opt_default(opt_t * opt, char *argv0)
opt->pcp_client = false;
opt->pcp_client_host = NULL;

rc_all_display = 0;

return;
}

Expand Down Expand Up @@ -587,6 +591,9 @@ void opt_args(opt_t * opt, int argc, char *argv[])

/* Continue processing regular options...
*/
case 'A':
rc_all_display = 1;
break;
case 'N':
opt->labels = false;
break;
Expand Down
4 changes: 4 additions & 0 deletions src/pdsh/opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ void opt_free(opt_t *);
*/
pers_t pdsh_personality(void);

/*
* Used to trigger the -A option in pipecmd.c, print every exit code on stdout
*/
int rc_all_display;

/*
* Return a list of the original remote args
Expand Down

0 comments on commit d1a5247

Please sign in to comment.