problem report: gawk 3.1.1

Pieter Prinsloo pietp@fedile.co.za
Wed Feb 19 22:44:00 GMT 2003


Hi.

Have a query/problem with gawk version 3.1.1-5 dated 17/Oct/2002.
(allthough the problem as stated is for cygwin - it can also be emulated in
Linux
with gawk 3.1.0)

Given the following example
====short awk program file==={
   one = sprintf("%s",$1);
   two = sprintf("%s",$2);
   printf("LEFT=%s:right=%s:\n",$1,$2);
   printf("left=%s:right=%s:\n",one,two);
}
===
If the input is a text file eg.
====short text file==left side of record 1 @ right side of record
left side of record 2 @ right side of record
left side of record 3 @ right side of record
===
I get different results depending on
a. How the program is started
     i. Using gawk on the input file
    ii. Using gawk after a pipe on the input file.
b. The line termination of the program file and the input file.
      i. Both files Dos terminated "CRLF"
     ii. The program file Dos terminated and the other is Unix terminated
LF"
    iii. The program file Unix terminated and the other is Dos terminated
    iv. Both files Unix terminated

a. Started as
    "gawk -F@  -f short.awk short.txt" and BOTH files are DOS terminated.
   the outputs.....
LEFT=left side of record 1 :right= right side of record:
left=left side of record 1 :right= right side of record:

b. Started as
   "tail -5 short.txt|gawk -F@  -f short.awk" and BOTH files is DOS
terminated.
   the outputs...
:EFT=left side of record 1 :right= right side of record
:eft=left side of record 1 :right= right side of record

So - the carriage return is included as part of parameter two.

The results vary - depending on the format of the two files.

Question - is this a problem with pipes? or with gawk? Am my understanding
of Cygwin in a Dos environment correct?

My current work around is to include a line like the following in the code
{sub("^M","",$2)}

Any comments or more info - please contact me.

bash, version 2.05b.0(8)
gawk version 3.1.1-5
tail (textutils) 2.0.21
on windoze 2000

Regards

Pieter Prinsloo.


Microsoft apparently thinks that R&D stands for 'Rewrap & Disguise'.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list