diff -ruN newt-0.51.6-old/whiptail.c newt-0.51.6/whiptail.c --- newt-0.51.6-old/whiptail.c 2004-02-23 11:42:46.000000000 +0000 +++ newt-0.51.6/whiptail.c 2004-02-23 12:28:01.000000000 +0000 @@ -77,6 +77,8 @@ int flags = 0; int defaultNo = 0; int separateOutput = 0; + int outputfd = 2; + FILE *output = stderr; const char * result; const char ** selections, ** next; char * title = NULL; @@ -178,6 +180,12 @@ exit(1); } + output = fdopen (outputfd, "w"); + if (output == NULL ) { + perror ("Cannot open output-fd\n"); + exit (DLG_ERROR); + } + if (mode == MODE_NONE) usage(); if (!(text = poptGetArg(optCon))) usage(); @@ -228,24 +236,24 @@ case MODE_INPUTBOX: rc = inputBox(text, height, width, optCon, flags, &result); - if (!rc) fprintf(stderr, "%s", result); + if (rc == DLG_OKAY) fprintf(output, "%s", result); break; case MODE_PASSWORDBOX: rc = inputBox(text, height, width, optCon, flags | FLAG_PASSWORD, &result); - if (rc == DLG_OKAY) fprintf (stderr, "%s", result); + if (rc == DLG_OKAY) fprintf (output, "%s", result); break; case MODE_MENU: rc = listBox(text, height, width, optCon, flags, &result); - if (!rc) fprintf(stderr, "%s", result); + if (rc == DLG_OKAY) fprintf(output, "%s", result); break; case MODE_RADIOLIST: rc = checkList(text, height, width, optCon, 1, flags, &selections); - if (!rc) { - fprintf(stderr, "%s", selections[0]); + if (rc == DLG_OKAY) { + fprintf(output, "%s", selections[0]); free(selections); } break; @@ -256,11 +264,11 @@ if (!rc) { for (next = selections; *next; next++) { if (!separateOutput) { - if (needSpace) putc(' ', stderr); - fprintf(stderr, "\"%s\"", *next); + if (needSpace) putc(' ', output); + fprintf(output, "\"%s\"", *next); needSpace = 1; } else { - fprintf(stderr, "%s\n", *next); + fprintf(output, "%s\n", *next); } }