Bug 147724

Summary: tcsh $< operator fails when fed by pipe tcsh 6.14.00-2
Product: [openSUSE] SUSE LINUX 10.0 Reporter: Carsten Rieck <carsten.rieck>
Component: BasesystemAssignee: Dr. Werner Fink <werner>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: carsten.rieck
Version: unspecified   
Target Milestone: ---   
Hardware: i686   
OS: SuSE Linux 10.0   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Carsten Rieck 2006-02-02 17:33:12 UTC
consider this script

#! /bin/tcsh -f
while (1)
  set i = $<
  echo "input: $i"
  if ("${i}x" != "x") then
    echo hej
  else
    echo exit
    exit 0
  endif
end

and run

alluser@mte-perjar:~> echo "fsdfdsf" |./test
input: fsdfdsf
hej
input: j
hej
input: j
hej
input: j
hej
input: j
hej
input: j
hej
input: j
hej
input: j
hej
input: j
hej
input: j
hej
input: j


... and goes on forever !!!

this just happens if you use a pipe !

alluser@mte-perjar:~> ./test
afdsa
input: afdsa
hej

input:
exit
alluser@mte-perjar:~>

it works fine in 6.08.00, 6.11.00, 6.12.00  (all SUSE)

I have not found anything reported yet and I am not sure if this is a tcsh problem or something else.
well, if you have some feedback on this I would be glad to here it.


Carsten Rieck
Comment 1 Dr. Werner Fink 2006-02-06 18:47:54 UTC
Just found the bug and the solution:

--- sh.dol.c
+++ sh.dol.c    2006-02-06 18:41:05.000000000 +0000
@@ -486,6 +486,8 @@
            char cbuf[MB_LEN_MAX];
            size_t cbp = 0;
 
+           memset(&cbuf[0], 0, sizeof(cbuf));
+
 #ifdef BSDSIGS
            sigmask_t omask = sigsetmask(sigblock(0) & ~sigmask(SIGINT));
 #else /* !BSDSIGS */
Comment 2 Dr. Werner Fink 2006-02-07 10:21:23 UTC
Fixed for next release of SuSE Linux.