Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement -A optional flag to return all exit codes on stdout #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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