From a8e6cf7ee1d68d05cf8e8ca49a44f3cc7190c97b Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 15 Feb 2015 15:43:04 +0000 Subject: [PATCH 01/19] Instead of swallowing the TZ environment variable, pass it on as MSYS_TZ It is true that pure Windows programs cannot handle the TZ variable well. However, the same is not true of Git, which handles the timezone environment variable quite well. Let's give it a chance by passing on the TZ environment variable as MSYS2_TZ. Signed-off-by: Johannes Schindelin --- winsup/cygwin/environ.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 1252e0a5cb..519665dc6a 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -1150,7 +1150,12 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc, #ifdef __MSYS__ /* Don't pass timezone environment to non-msys applications */ if (!keep_posix && ascii_strncasematch(*srcp, "TZ=", 3)) - goto next1; + { + *dstp = (char *) cmalloc (HEAP_1_STR, strlen (*srcp) + 7); + strcpy (*dstp, "MSYS2_"); + strcpy (*dstp + 6, *srcp); + goto next0; + } #endif /* Look for entries that require special attention */ for (unsigned i = 0; i < SPENVS_SIZE; i++) From 66918a010ee89fda34bb2b8e835d520877f4c2ae Mon Sep 17 00:00:00 2001 From: Karsten Blees Date: Wed, 15 Apr 2015 21:05:42 +0200 Subject: [PATCH 02/19] Pass the TZ variable to non-msys programs if it is standard-compliant Native Windows programs (linked to MSVCRT) understand a subset of the TZ environment variable syntax [1], namely "std offset dst" (e.g."CET-1CEST" for central european time, see _tzset() MSDN documentation [2]). Implementation-defined forms (starting with ':') and rules when to switch to DST are not supported by MSVCRT. MSYS2 uses a non-standard TZ format (e.g. "TZ=Europe/Berlin", without ':'). When preparing the environment for non-msys programs, pass the TZ variable on if it looks standard-compliant (as recognized by MSVCRT). Otherwise drop the variable and let MSVCRT determine system timezone settings via native Windows APIs. This allows us to use standard-compliant TZ settings that also affect non-msys programs, as needed e.g. by the git test suite. [1] http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html [2] https://msdn.microsoft.com/library/90s5c885.aspx Signed-off-by: Karsten Blees --- winsup/cygwin/environ.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 519665dc6a..fb6de9be0a 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -1148,13 +1148,16 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc, { bool calc_tl = !no_envblock; #ifdef __MSYS__ - /* Don't pass timezone environment to non-msys applications */ + /* Don't pass non-standard timezone to non-msys applications */ if (!keep_posix && ascii_strncasematch(*srcp, "TZ=", 3)) { - *dstp = (char *) cmalloc (HEAP_1_STR, strlen (*srcp) + 7); - strcpy (*dstp, "MSYS2_"); - strcpy (*dstp + 6, *srcp); - goto next0; + const char *v = *srcp + 3; + if (*v == ':') + goto next1; + for (; *v; v++) + if (!isalpha(*v) && !isdigit(*v) && + *v != '-' && *v != '+' && *v != ':') + goto next1; } #endif /* Look for entries that require special attention */ From 51c6ef4f8d68108e1d6a9e770d858ad6e4f9a473 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 17 Feb 2015 15:56:15 +0000 Subject: [PATCH 03/19] Do not add a trailing slash when converting / to a Win32 path This resembles MSys1' behavior on which Git's t0060 relies. Signed-off-by: Johannes Schindelin --- winsup/cygwin/path.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 8e4d57fb1b..083b1cff70 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -734,11 +734,11 @@ path_conv::check (const char *src, unsigned opt, need_directory = 1; *--tail = '\0'; } - /* Special case for "/" must set need_directory, without removing + /* Special case for "/" must not set need_directory, neither remove trailing slash */ else if (tail == path_copy + 1 && isslash (tail[-1])) { - need_directory = 1; + need_directory = 0; } path_end = tail; From 862f33b67800999cab91a314291573e59a533c93 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Feb 2015 10:45:01 +0000 Subject: [PATCH 04/19] Stop assuming that there are no spaces in POSIX-style paths Git's test suite most prominently sports a POSIX path with a space in it: the tests are executed in directories whose names have the form 'trash directory.t0123-blub'. Therefore, we *must* handle those names correctly. This fix makes Git's t1504-ceiling-dirs.sh pass. Signed-off-by: Johannes Schindelin --- winsup/cygwin/msys2_path_conv.cc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc index 74ebd2e0b6..3ee1bd3ae0 100644 --- a/winsup/cygwin/msys2_path_conv.cc +++ b/winsup/cygwin/msys2_path_conv.cc @@ -200,7 +200,7 @@ void ppl_convert(const char** from, const char* to, char** dst, const char* dste void find_end_of_posix_list(const char** to, int* in_string) { - for (; **to != '\0' && (in_string ? (**to != *in_string) : **to != ' '); ++*to) { + for (; **to != '\0' && (!in_string || **to != *in_string); ++*to) { } if (**to == *in_string) { @@ -299,12 +299,6 @@ const char* convert(char *dst, size_t dstlen, const char *src) { } continue; } - - if (isspace(*srcit)) { - //sub_convert(&srcbeg, &srcit, &dstit, dstend, &in_string); - //srcbeg = srcit + 1; - break; - } } sub_convert(&srcbeg, &srcit, &dstit, dstend, &in_string); From d625293945567f0aac82814b53741268c7838497 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Feb 2015 12:32:17 +0000 Subject: [PATCH 05/19] Pass environment variables with empty values There is a difference between an empty value and an unset environment variable. We should not confuse both; If the user wants to unset an environment variable, they can certainly do so (unsetenv(3), or in the shell: 'unset ABC'). This fixes Git's t3301-notes.sh, which overrides environment variables with empty values. Signed-off-by: Johannes Schindelin --- winsup/cygwin/environ.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index fb6de9be0a..2ab6d2885b 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -1263,7 +1263,7 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc, Note that this doesn't stop invalid strings without '=' in it etc., but we're opting for speed here for now. Adding complete checking would be pretty expensive. */ - if (len == 1 || !*rest) + if (len == 1) continue; /* See if this entry requires posix->win32 conversion. */ From 60d1d9fc0b539df0787cacd744346ee017968768 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 20 Feb 2015 13:56:22 +0000 Subject: [PATCH 06/19] Handle 8-bit characters under LOCALE=C Even when the character set is specified as ASCII, we should handle data outside the 7-bit range gracefully by simply copying it, even if it is technically no longer ASCII. This fixes several of Git for Windows' tests, e.g. t7400. Signed-off-by: Johannes Schindelin --- newlib/libc/stdlib/mbtowc_r.c | 2 +- newlib/libc/stdlib/wctomb_r.c | 2 +- winsup/cygwin/strfuncs.cc | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/newlib/libc/stdlib/mbtowc_r.c b/newlib/libc/stdlib/mbtowc_r.c index 986595cfdc..47287564c2 100644 --- a/newlib/libc/stdlib/mbtowc_r.c +++ b/newlib/libc/stdlib/mbtowc_r.c @@ -48,7 +48,7 @@ _DEFUN (__ascii_mbtowc, (r, pwc, s, n, charset, state), if (n == 0) return -2; -#ifdef __CYGWIN__ +#ifdef STRICTLY_7BIT_ASCII if ((wchar_t)*t >= 0x80) { r->_errno = EILSEQ; diff --git a/newlib/libc/stdlib/wctomb_r.c b/newlib/libc/stdlib/wctomb_r.c index c93962fa43..e70349f33f 100644 --- a/newlib/libc/stdlib/wctomb_r.c +++ b/newlib/libc/stdlib/wctomb_r.c @@ -41,7 +41,7 @@ _DEFUN (__ascii_wctomb, (r, s, wchar, charset, state), if (s == NULL) return 0; -#ifdef __CYGWIN__ +#ifdef STRICTLY_7BIT_ASCII if ((size_t)wchar >= 0x80) #else if ((size_t)wchar >= 0x100) diff --git a/winsup/cygwin/strfuncs.cc b/winsup/cygwin/strfuncs.cc index 94ce82ce57..ddec511230 100644 --- a/winsup/cygwin/strfuncs.cc +++ b/winsup/cygwin/strfuncs.cc @@ -618,7 +618,11 @@ sys_cp_mbstowcs (mbtowc_p f_mbtowc, const char *charset, wchar_t *dst, to store them in a symmetric way. */ bytes = 1; if (dst) +#ifdef STRICTLY_7BIT_ASCII *ptr = L'\xf000' | *pmbs; +#else + *ptr = *pmbs; +#endif memset (&ps, 0, sizeof ps); } From 6847fc601e07c294f588ecaabd5600595667267e Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 20 Feb 2015 11:54:47 +0000 Subject: [PATCH 07/19] Mention the extremely useful small_printf() function It came in real handy while debugging an issue that strace 'fixed'. Signed-off-by: Johannes Schindelin --- winsup/cygwin/how-to-debug-cygwin.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/winsup/cygwin/how-to-debug-cygwin.txt b/winsup/cygwin/how-to-debug-cygwin.txt index fcf53a27f2..703d21f608 100644 --- a/winsup/cygwin/how-to-debug-cygwin.txt +++ b/winsup/cygwin/how-to-debug-cygwin.txt @@ -126,3 +126,9 @@ set CYGWIN_DEBUG=cat.exe:gdb.exe program will crash, probably in small_printf. At that point, a 'bt' command should show you the offending call to strace_printf with the improper format string. + +9. Debug output without strace + + If you cannot use gdb, or if the program behaves differently using strace + for whatever reason, you can still use the small_printf() function to + output debugging messages directly to stderr. From ff6712a0b34bb211318f046d7752a48bc1f94689 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Feb 2015 11:06:15 +0000 Subject: [PATCH 08/19] Add a helpful debug message for posix-to-windows conversion Signed-off-by: Johannes Schindelin --- winsup/cygwin/msys2_path_conv.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc index 3ee1bd3ae0..93d49deec1 100644 --- a/winsup/cygwin/msys2_path_conv.cc +++ b/winsup/cygwin/msys2_path_conv.cc @@ -237,6 +237,7 @@ void find_end_of_rooted_path(const char** from, const char** to, int* in_string) void sub_convert(const char** from, const char** to, char** dst, const char* dstend, int* in_string) { const char* copy_from = *from; path_type type = find_path_start_and_type(from, false, *to); + debug_printf("found type %d for path %s", type, copy_from); if (type == POSIX_PATH_LIST) { find_end_of_posix_list(to, in_string); From 222d8520d71d670f8f05cb2c03b34495669661c1 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 22 Feb 2015 18:28:02 +0100 Subject: [PATCH 09/19] Avoid unnecessary recursion in find_path_start_and_type() Signed-off-by: Johannes Schindelin --- winsup/cygwin/msys2_path_conv.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc index 93d49deec1..340e99f2ad 100644 --- a/winsup/cygwin/msys2_path_conv.cc +++ b/winsup/cygwin/msys2_path_conv.cc @@ -335,8 +335,10 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en if (*it == '\0' || it == end) return NONE; - if (!isalnum(*it) && *it != '/' && *it != '\\' && *it != ':' && *it != '-' && *it != '.') { - return find_path_start_and_type(move(src, 1), true, end); + while (!isalnum(*it) && *it != '/' && *it != '\\' && *it != ':' && *it != '-' && *it != '.') { + recurse = true; + it = ++*src; + if (it == end || *it == '\0') return NONE; } path_type result = NONE; From 1204d7aa00a8d71caea779e8e1a6e7e4f3fa2c99 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 15 Feb 2015 11:45:48 +0000 Subject: [PATCH 10/19] Leave arguments starting with a tilde or quote alone It is not a good idea to expand, say, ~/.gitconfig partially: replacing it by ~C:\msys64\.gitconfig is most likely the wrong thing to do! Signed-off-by: Johannes Schindelin --- winsup/cygwin/msys2_path_conv.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc index 340e99f2ad..25882abb07 100644 --- a/winsup/cygwin/msys2_path_conv.cc +++ b/winsup/cygwin/msys2_path_conv.cc @@ -335,6 +335,13 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en if (*it == '\0' || it == end) return NONE; + /* Let's not convert ~/.file to ~C:\msys64\.file */ + if (*it == '~') { +skip_p2w: + *src = end; + return NONE; + } + while (!isalnum(*it) && *it != '/' && *it != '\\' && *it != ':' && *it != '-' && *it != '.') { recurse = true; it = ++*src; From 50158ab6ec5bab24c39508d47ae9ded8e1cb501a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Feb 2015 11:07:17 +0000 Subject: [PATCH 11/19] Leave Git's :name and :/message arguments alone, please Signed-off-by: Johannes Schindelin --- winsup/cygwin/msys2_path_conv.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc index 25882abb07..8f8c016694 100644 --- a/winsup/cygwin/msys2_path_conv.cc +++ b/winsup/cygwin/msys2_path_conv.cc @@ -342,6 +342,12 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en return NONE; } + /* + * Prevent Git's :file.txt and :/message syntax from beeing modified. + */ + if (*it == ':') + goto skip_p2w; + while (!isalnum(*it) && *it != '/' && *it != '\\' && *it != ':' && *it != '-' && *it != '.') { recurse = true; it = ++*src; From dfd0fd2589a48de6be18b4a90fc4b71b76c91fda Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 22 Feb 2015 18:33:48 +0100 Subject: [PATCH 12/19] Leave paths containing any special characters alone Signed-off-by: Johannes Schindelin --- winsup/cygwin/msys2_path_conv.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc index 8f8c016694..e337ce02a2 100644 --- a/winsup/cygwin/msys2_path_conv.cc +++ b/winsup/cygwin/msys2_path_conv.cc @@ -348,6 +348,20 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en if (*it == ':') goto skip_p2w; + while (it != end && *it) { + switch (*it) { + case '`': + case '\'': + case '"': + case '*': + case '?': + case '[': + case ']': + goto skip_p2w; + ++it; + } + it = *src; + while (!isalnum(*it) && *it != '/' && *it != '\\' && *it != ':' && *it != '-' && *it != '.') { recurse = true; it = ++*src; From 0263e5e0da0bba5516efa5e2ee45f7de169d7529 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Feb 2015 11:07:17 +0000 Subject: [PATCH 13/19] Leave paths containing '/~' alone We do not perform tilde expansion in the MSys2 runtime; let's leave those paths intact for programs that want to expand such paths themselves. Signed-off-by: Johannes Schindelin --- winsup/cygwin/msys2_path_conv.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc index e337ce02a2..19aa8d6b58 100644 --- a/winsup/cygwin/msys2_path_conv.cc +++ b/winsup/cygwin/msys2_path_conv.cc @@ -358,6 +358,10 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en case '[': case ']': goto skip_p2w; + case '/': + if (it + 1 < end && it[1] == '~') + goto skip_p2w; + break; ++it; } it = *src; From 9eba13aba5d38561a10a8fb6566602141d9b2f31 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Feb 2015 11:07:17 +0000 Subject: [PATCH 14/19] Skip posix-to-windows conversion when '::' is seen The substring '::' most likely denotes an IPv6 address, not a path. Signed-off-by: Johannes Schindelin --- winsup/cygwin/msys2_path_conv.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc index 19aa8d6b58..c256f84c50 100644 --- a/winsup/cygwin/msys2_path_conv.cc +++ b/winsup/cygwin/msys2_path_conv.cc @@ -362,6 +362,11 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en if (it + 1 < end && it[1] == '~') goto skip_p2w; break; + case ':': + // Avoid mangling IPv6 addresses + if (it + 1 < end && it[1] == ':') + goto skip_p2w; + break; ++it; } it = *src; From ffebf192cf3fd50e69146785bebe1e54abefa1ae Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Feb 2015 11:07:17 +0000 Subject: [PATCH 15/19] Also leave Git's :./ syntax alone This fixes Git's t1506-rev-parse-diagnosis.sh Signed-off-by: Johannes Schindelin --- winsup/cygwin/msys2_path_conv.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc index c256f84c50..40e01a245a 100644 --- a/winsup/cygwin/msys2_path_conv.cc +++ b/winsup/cygwin/msys2_path_conv.cc @@ -366,6 +366,14 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en // Avoid mangling IPv6 addresses if (it + 1 < end && it[1] == ':') goto skip_p2w; + + // Leave Git's :./name syntax alone + if (it + 1 < end && it[1] == '.') { + if (it + 2 < end && it[2] == '/') + goto skip_p2w; + if (it + 3 < end && it[2] == '.' && it[3] == '/') + goto skip_p2w; + } break; ++it; } From f19d6f6532419f2f6891a4f974552a6583791b89 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Feb 2015 11:07:17 +0000 Subject: [PATCH 16/19] Arguments starting with '@@' are no paths ... so let's skip posix-to-windows conversion on such parameters. This fixes Git's t1508-at-combinations.sh. Signed-off-by: Johannes Schindelin --- winsup/cygwin/msys2_path_conv.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc index 40e01a245a..f63e140e0d 100644 --- a/winsup/cygwin/msys2_path_conv.cc +++ b/winsup/cygwin/msys2_path_conv.cc @@ -375,6 +375,11 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en goto skip_p2w; } break; + case '@': + // Paths do not contain '@@' + if (it + 1 < end && it[1] == '@') + goto skip_p2w; + } ++it; } it = *src; From 6211f262935935a5c0dc89b9846750844a2e32ac Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Feb 2015 11:07:17 +0000 Subject: [PATCH 17/19] Prevent scp-style arguments from being mangled An argument like me@example.com:/tmp/ is not something we should convert into a Windows path; Use the absence of a slash before the colon as a tell-tale that it is *not* a POSIX path list (exception: if the part left of the colon is "." or ".."). Signed-off-by: Johannes Schindelin --- winsup/cygwin/msys2_path_conv.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc index f63e140e0d..ae83d5be16 100644 --- a/winsup/cygwin/msys2_path_conv.cc +++ b/winsup/cygwin/msys2_path_conv.cc @@ -449,6 +449,8 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en int starts_with_minus = 0; int starts_with_minus_alpha = 0; + int only_dots = *it == '.'; + int has_slashes = 0; if (*it == '-') { starts_with_minus = 1; it += 1; @@ -489,11 +491,17 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en if (ch == '/' && *(it2 + 1) == '/') { return URL; } else { + if (!only_dots && !has_slashes) + goto skip_p2w; return POSIX_PATH_LIST; } } else if (memchr(it2, '=', end - it) == NULL) { return SIMPLE_WINDOWS_PATH; } + } else if (ch != '.') { + only_dots = 0; + if (ch == '/' || ch == '\\') + has_slashes = 1; } } From 2b5d3d38d7daf1fe190cb1a2355041a7641dced2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A7=88=EB=88=84=EC=97=98?= Date: Mon, 9 Mar 2015 16:24:43 +0100 Subject: [PATCH 18/19] Fixed path converting with non ascii char. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a non ascii char is at the beginning of a path the current conversion destroys the path. This fix will prevent this with an extra check for non-ascii UTF-8 characters. Helped-by: Johannes Schindelin Signed-off-by: 마누엘 --- winsup/cygwin/msys2_path_conv.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc index ae83d5be16..3906aa3fbc 100644 --- a/winsup/cygwin/msys2_path_conv.cc +++ b/winsup/cygwin/msys2_path_conv.cc @@ -384,7 +384,7 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en } it = *src; - while (!isalnum(*it) && *it != '/' && *it != '\\' && *it != ':' && *it != '-' && *it != '.') { + while (!isalnum(*it) && !(0x80 & *it) && *it != '/' && *it != '\\' && *it != ':' && *it != '-' && *it != '.') { recurse = true; it = ++*src; if (it == end || *it == '\0') return NONE; From 2fb55d6adca75bd343901ae267ca5231c2083e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A7=88=EB=88=84=EC=97=98?= Date: Wed, 17 Jun 2015 09:30:41 +0200 Subject: [PATCH 19/19] path-conversion: Introduce ability to switch off conversion. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When calling windows native apps from MSYS2, the runtime tries to convert commandline arguments by a specific set of rules. See [MinGW wiki] (http://www.mingw.org/wiki/Posix_path_conversion). If the user does not want that behavior on a big scale, e.g. inside a bash script, the user can now set the the environment variable `MSYS_NO_PATHCONV` when calling native windows commands. Signed-off-by: 마누엘 --- winsup/cygwin/msys2_path_conv.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc index 3906aa3fbc..6377e12cca 100644 --- a/winsup/cygwin/msys2_path_conv.cc +++ b/winsup/cygwin/msys2_path_conv.cc @@ -342,6 +342,14 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en return NONE; } + /* + * Skip path mangling when environment indicates it. + */ + const char *no_pathconv = getenv ("MSYS_NO_PATHCONV"); + + if (no_pathconv) + goto skip_p2w; + /* * Prevent Git's :file.txt and :/message syntax from beeing modified. */