summaryrefslogtreecommitdiffstats
path: root/generic/tclPipe.c
diff options
context:
space:
mode:
authorandreas_kupries <akupries@shaw.ca>2005-10-05 22:09:03 (GMT)
committerandreas_kupries <akupries@shaw.ca>2005-10-05 22:09:03 (GMT)
commit2a5ae89c4e4c6574518b806cb6e6586823450c5d (patch)
tree80d00d3f488430f8579d00868bce18dab49964a5 /generic/tclPipe.c
parent5538a8f05d419a3daff75d9dd5fa460fae5dad75 (diff)
downloadtcl-2a5ae89c4e4c6574518b806cb6e6586823450c5d.zip
tcl-2a5ae89c4e4c6574518b806cb6e6586823450c5d.tar.gz
tcl-2a5ae89c4e4c6574518b806cb6e6586823450c5d.tar.bz2
* generic/tclPipe.c (TclCreatePipeline): Fixed [SF Tcl Bug
1109294]. Applied the patch provided by David Gravereaux.
Diffstat (limited to 'generic/tclPipe.c')
-rw-r--r--generic/tclPipe.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/generic/tclPipe.c b/generic/tclPipe.c
index f7bc038..082fcda 100644
--- a/generic/tclPipe.c
+++ b/generic/tclPipe.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclPipe.c,v 1.12 2005/07/28 10:55:36 dkf Exp $
+ * RCS: @(#) $Id: tclPipe.c,v 1.13 2005/10/05 22:09:04 andreas_kupries Exp $
*/
#include "tclInt.h"
@@ -496,6 +496,7 @@ TclCreatePipeline(interp, argc, argv, pidArrayPtr, inPipePtr,
* 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;
@@ -568,7 +569,7 @@ TclCreatePipeline(interp, argc, argv, pidArrayPtr, inPipePtr,
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);
@@ -577,8 +578,9 @@ TclCreatePipeline(interp, argc, argv, pidArrayPtr, inPipePtr,
skip = 2;
}
} else {
+ nextArg = ((i + 1) == argc) ? NULL : argv[i + 1];
inputLiteral = NULL;
- inputFile = FileForRedirect(interp, p, 1, argv[i], argv[i+1],
+ inputFile = FileForRedirect(interp, p, 1, argv[i], nextArg,
O_RDONLY, &skip, &inputClose, &inputRelease);
if (inputFile == NULL) {
goto error;
@@ -630,7 +632,8 @@ TclCreatePipeline(interp, argc, argv, pidArrayPtr, inPipePtr,
TclpReleaseFile(outputFile);
}
}
- outputFile = FileForRedirect(interp, p, atOK, argv[i], argv[i+1],
+ nextArg = ((i + 1) == argc) ? NULL : argv[i + 1];
+ outputFile = FileForRedirect(interp, p, atOK, argv[i], nextArg,
flags, &skip, &outputClose, &outputRelease);
if (outputFile == NULL) {
goto error;
@@ -684,8 +687,9 @@ TclCreatePipeline(interp, argc, argv, pidArrayPtr, inPipePtr,
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;
}
@@ -854,7 +858,6 @@ TclCreatePipeline(interp, argc, argv, pidArrayPtr, inPipePtr,
}
}
}
- argv[lastArg] = NULL;
/*
* If this is the last segment, use the specified outputFile.
@@ -862,9 +865,10 @@ TclCreatePipeline(interp, argc, argv, pidArrayPtr, inPipePtr,
* 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);