FYI:
I installed version '93u 2011-02-08' on a CygWin installation and have been unable to
reproduce the problem.

----- Original Message ----- From: "John S. Urban" <[email protected]> To: "Janis Papanagnou" <[email protected]>; <[email protected]>
Sent: Saturday, December 10, 2011 6:53 PM
Subject: Re: [ast-users] Corrupted output from a here document in ksh


The machines I tested on are not ones I can change; but one machine is only a few weeks old and is running SUSE 11
and ksh version
93t+ 2010-03-05
and I get the problem. I have duplicated it at three unrelated sites; but all were Linux platforms. I will install the latest version on one of my own machines. Thank you for testing this. I am very surprised the version you tested with does not have a problem. the only ksh(1) version I tested with that did not show a problem was ksh88; but any other shell I tried that could execute the very simple script generated by the example always just showed the "6".

In the output I see the first
8080 lines are OK; then two blank lines are put out; then two blank lines are put out after every 4096 lines; the file
output has 500121 lines instead of 500000.

The longer example has changed characters instead of added blank
lines. The first difference is at line 3149 at byte 40925; 183 lines are corrupted in total. All the lines in the file should start out
678 but some of them start with 778, 898, and 967 in a recurring pattern.




----- Original Message ----- From: "Janis Papanagnou" <[email protected]>
To: <[email protected]>; <[email protected]>
Sent: Saturday, December 10, 2011 4:24 PM
Subject: RE: [ast-users] Corrupted output from a here document in ksh



I am running a ksh Version JM 93t+ 2009-05-01,
and if I run your test script I get a single line with
content "6".

Have you tried updating to a newer ksh?

________________________________
From: [email protected]
To: [email protected]
Subject: Re: [ast-users] Corrupted output from a here document in ksh
Date: Sat, 10 Dec 2011 15:58:42 -0500

This reproduces for me on SUSE 10, SUSE 11, and RedHat.
Can anyone verify they seem the same symptoms? There have
been no replies.
----- Original Message ----- From: John S. Urban<mailto:[email protected]>
To: [email protected]<mailto:[email protected]>
Sent: Thursday, December 08, 2011 9:30 PM
Subject: [ast-users] Corrupted output from a here document in ksh

When lines begin with the same characters as the marker used
for a here document the data generated is corrupted. This problem
appears to be long-standing but could corrupt critical data. It was
tested with
     93t+ 2010-03-05
     93s+ 2008-01-31
     1993-12-28 r
Other common shells (csh,tcsh,bash,pdksh) do not cause the
corruption.

The simplest script that I could make to show the problem is
#!/bin/ksh
(
   echo '#!/bin/ksh'
   echo 'cat <<6789'
   yes 6|head -500000
   echo 6789
) >/tmp/test.ksh
/bin/ksh /tmp/test.ksh |uniq

Which should generate one line of output ("6").

Very surprisingly, if I take the "echo '#!/bin/ksh'" line out it works.

IA script that seems to cause errors much more reliably is the following:
#!/bin/ksh
#################################################
# usage:
# testit [pdksh|bash|sh|csh|tcsh|ash|ksh|zsh...]
# default is ksh
#################################################
/bin/rm -f /tmp/test.$XSHELL /tmp/data1 /tmp/data2
export TESTSTRING MARKER
TESTSTRING=6 MARKER=6789
TESTSTRING=67896789abcd MARKER=6789
XSHELL=${1:-ksh}
#################################################
# make script that is nothing but a cat of a here
# document. Capture what you expect the script
# into data1.
#-----------------------------------------------#
(
cat <<EOF
#!/bin/$XSHELL
#cat <<\\$MARKER
cat <<$MARKER
EOF
yes "$TESTSTRING"|head -500000|tee /tmp/data1
echo "$MARKER"
) >/tmp/test.$XSHELL
#################################################
# execute the script and put output in data2
$XSHELL /tmp/test.$XSHELL >/tmp/data2
#################################################
# compare data1 and data2
#sum /tmp/data1 /tmp/data2
uniq /tmp/data2
wc /tmp/data1 /tmp/data2
if ! cmp /tmp/data1 /tmp/data2
then
    diff /tmp/data1 /tmp/data2
    echo 'UNEXPECTED LINES:'
    grep -n -v "^$TESTSTRING\$" /tmp/data2
else
    echo data1 and data2 are SAME for $XSHELL
fi
#################################################
exit
#################################################

________________________________

_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

_______________________________________________ ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users


_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users


_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to