Attachment "1109294.diff" to
ticket [1109294fff]
added by
davidw
2005-01-26 06:15:41.
Index: generic/tclPipe.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclPipe.c,v
retrieving revision 1.10
diff -u -r1.10 tclPipe.c
--- generic/tclPipe.c 26 Oct 2004 20:24:15 -0000 1.10
+++ generic/tclPipe.c 25 Jan 2005 23:01:41 -0000
@@ -507,6 +507,7 @@
* closed when cleaning up. */
int errorRelease = 0;
CONST char *p;
+ CONST char *nextArg;
int skip, lastBar, lastArg, i, j, atOK, flags, errorToOutput = 0;
Tcl_DString execBuffer;
TclFile pipeIn;
@@ -580,7 +581,7 @@
inputLiteral = p + 1;
skip = 1;
if (*inputLiteral == '\0') {
- inputLiteral = argv[i + 1];
+ inputLiteral = ((i + 1) == argc) ? NULL : argv[i + 1];
if (inputLiteral == NULL) {
Tcl_AppendResult(interp, "can't specify \"", argv[i],
"\" as last word in command", (char *) NULL);
@@ -589,9 +590,10 @@
skip = 2;
}
} else {
+ nextArg = ((i + 1) == argc) ? NULL : argv[i + 1];
inputLiteral = NULL;
inputFile = FileForRedirect(interp, p, 1, argv[i],
- argv[i + 1], O_RDONLY, &skip, &inputClose, &inputRelease);
+ nextArg, O_RDONLY, &skip, &inputClose, &inputRelease);
if (inputFile == NULL) {
goto error;
}
@@ -636,8 +638,9 @@
TclpReleaseFile(outputFile);
}
}
+ nextArg = ((i + 1) == argc) ? NULL : argv[i + 1];
outputFile = FileForRedirect(interp, p, atOK, argv[i],
- argv[i + 1], flags, &skip, &outputClose, &outputRelease);
+ nextArg, flags, &skip, &outputClose, &outputRelease);
if (outputFile == NULL) {
goto error;
}
@@ -689,8 +692,9 @@
errorToOutput = 2;
skip = 1;
} else {
+ nextArg = ((i + 1) == argc) ? NULL : argv[i + 1];
errorFile = FileForRedirect(interp, p, atOK, argv[i],
- argv[i + 1], flags, &skip, &errorClose, &errorRelease);
+ nextArg, flags, &skip, &errorClose, &errorRelease);
if (errorFile == NULL) {
goto error;
}
@@ -857,7 +861,6 @@
}
}
}
- argv[lastArg] = NULL;
/*
* If this is the last segment, use the specified outputFile.
@@ -865,9 +868,10 @@
* curInFile for the next segment of the pipe.
*/
- if (lastArg == argc) {
+ if (lastArg == argc) {
curOutFile = outputFile;
} else {
+ argv[lastArg] = NULL;
if (TclpCreatePipe(&pipeIn, &curOutFile) == 0) {
Tcl_AppendResult(interp, "couldn't create pipe: ",
Tcl_PosixError(interp), (char *) NULL);