RFR: JDK-8176033: New cygwin grep does not match \r as newline

Erik Joelsson erik.joelsson at oracle.com
Wed Mar 1 13:04:04 UTC 2017


In our configure code for rewriting cygwin paths reliably, we use this 
construct to find the root of the cygwin installation:

# The cmd output ends with Windows line endings (CR/LF), the grep 
command will strip that away
cygwin_winpath_root=`cd / ; cmd /c cd | $GREP ".*"`

This used to work fine for a long time, but with the latest version of 
cygwin grep, it no longer removes \r from the string. A more robust 
implementation would be to instead use tr to explicitly remove both \r 
and \n.

Bug: https://bugs.openjdk.java.net/browse/JDK-8176033

Patch:

diff -r fe8466adaef8 common/autoconf/basics_windows.m4
--- a/common/autoconf/basics_windows.m4 Fri Feb 24 12:01:32 2017 +0100
+++ b/common/autoconf/basics_windows.m4 Wed Mar 01 10:50:44 2017 +0100
@@ -329,8 +329,8 @@
        AC_MSG_ERROR([Something is wrong with your cygwin installation 
since I cannot find cygpath.exe in your path])
      fi
      AC_MSG_CHECKING([cygwin root directory as unix-style path])
-    # The cmd output ends with Windows line endings (CR/LF), the grep 
command will strip that away
-    cygwin_winpath_root=`cd / ; cmd /c cd | $GREP ".*"`
+    # The cmd output ends with Windows line endings (CR/LF)
+    cygwin_winpath_root=`cd / ; cmd /c cd | $TR -d '\r\n'`
      # Force cygpath to report the proper root by including a trailing 
space, and then stripping it off again.
      CYGWIN_ROOT_PATH=`$CYGPATH -u "$cygwin_winpath_root " | $CUT -f 1 
-d " "`
      AC_MSG_RESULT([$CYGWIN_ROOT_PATH])

/Erik




More information about the build-dev mailing list