Tcl Source Code

Artifact [314c26a974]
Login

Artifact 314c26a97409186ae238650211b5e0d5c12233c0:

Attachment "pipe.85.udiff" to ticket [768659ffff] added by andreas_kupries 2006-03-15 06:34:51.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/tcl/tcl/ChangeLog,v
retrieving revision 1.2975
diff -u -r1.2975 ChangeLog
--- ChangeLog	14 Mar 2006 22:52:16 -0000	1.2975
+++ ChangeLog	14 Mar 2006 23:31:38 -0000
@@ -1,5 +1,11 @@
 2006-03-14  Andreas Kupries <[email protected]>
 
+	* generic/tclPipe.c (TclCreatePipeline): Modified the processing
+	  of pipebars to fail if the last bar is followed only by
+	  redirections. [Bug 768659].
+
+2006-03-14  Andreas Kupries <[email protected]>
+
 	* doc/fconfigure.n: Clarified that -translation is binary is
 	  reported as lf when queried, because it is identical to lf,
 	  except for the special additional behaviour when setting
Index: generic/tclPipe.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclPipe.c,v
retrieving revision 1.17
diff -u -r1.17 tclPipe.c
--- generic/tclPipe.c	16 Jan 2006 19:38:15 -0000	1.17
+++ generic/tclPipe.c	14 Mar 2006 23:31:38 -0000
@@ -485,7 +485,7 @@
     int errorRelease = 0;
     CONST char *p;
     CONST char *nextArg;
-    int skip, lastBar, lastArg, i, j, atOK, flags, errorToOutput = 0;
+    int skip, lastBar, lastArg, i, j, atOK, flags, needCmd, errorToOutput = 0;
     Tcl_DString execBuffer;
     TclFile pipeIn;
     TclFile curInFile, curOutFile, curErrFile;
@@ -523,6 +523,7 @@
 
     lastBar = -1;
     cmdCount = 1;
+    needCmd = 1;
     for (i = 0; i < argc; i++) {
 	errorToOutput = 0;
 	skip = 0;
@@ -541,6 +542,7 @@
 	    }
 	    lastBar = i;
 	    cmdCount++;
+	    needCmd = 1;
 	    break;
 
 	case '<':
@@ -683,6 +685,11 @@
 		}
 	    }
 	    break;
+
+	default:
+	  /* Got a command word, not a redirection */
+	  needCmd = 0;
+	  break;
 	}
 
 	if (skip != 0) {
@@ -694,6 +701,15 @@
 	}
     }
 
+    if (needCmd) {
+	/* We had a bar followed only by redirections. */
+
+        Tcl_SetResult(interp,
+		      "illegal use of | or |& in command",
+		      TCL_STATIC);
+	goto error;
+    }
+
     if (inputFile == NULL) {
 	if (inputLiteral != NULL) {
 	    /*