This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

B19.1: make $(shell) output crlf problem with perl

I believe I have found a bug in GNU make in cygwin32 b19.1.  I'm running
under NT 4.0 service pack 3.

Bug summary: $(shell) constructs that run perl scripts return strings that
end in \r, which they shouldn't.

Consider this Makefile:

    VARIABLE1=$(shell script1)
    VARIABLE2=$(shell script2)
    VARIABLE2=$(shell script3)

    	echo $(VARIABLE1)/bar

    	echo $(VARIABLE2)/bar

    	echo $(VARIABLE3)/bar

And this shell script called script1:

    #! /bin/sh
    echo foo

And this perl script called script2:

    #! /usr/local/bin/perl
    print "/foo\n";

And this c program called script3.c:

    main () { printf("/foo\n"); }

Script1 has this output:

    bash-2.01$ script1 | od -c
    0000000   /   f   o   o  \r  \n

and script2 has this output:

    bash-2.01$ script2 | od -c
    0000000   /   f   o   o  \r  \n

and script3 has this output:

    bash-2.01$ script3 | od -c
    0000000   /   f   o   o  \r  \n

Then consider what happens when you type "make test1", "make test2", and  "make test3":

    bash-2.01$ make test1
    echo /foo/bar
    bash-2.01$ make test2   
    /bar /foo
    bash-2.01$ make test3
    echo /foo/bar

If you look a little closer:

    bash-2.01$ make test2 | od -c
    0000000   e   c   h   o       /   f   o   o  \r   /   b   a   r  \r  \n
    0000020   /   f   o   o  \r   /   b   a   r  \r  \n

Something different happens when make grabs the output of script2 than when
it calls script1 or script3.  It appears that in one case, it removes the
\r\n and in the other only removes the \n leaving the \r at the end of the

The fact that only "test2" failed implies this is a problem with perl, but I
don't think it is, since it is clear that the perl in this case is returning
something with a \r both inside and outside the make environment.

The perl for Win32 we're using is Perl 5.004 from Hip Communications and was downloaded
from http:/

I am not on the gnu-win32 mailing list.

                       --Jim Dempsey--
For help on using this list (especially unsubscribing), send a message to
"" with one line of text: "help".

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]