diff --git a/runtime/path_convert/src/main.cpp b/runtime/path_convert/src/main.cpp
index bdc4fcb..8b29b46 100644
--- a/runtime/path_convert/src/main.cpp
+++ b/runtime/path_convert/src/main.cpp
@@ -21,7 +21,7 @@ typedef struct test_data_t {
#error "Need to define both MSYSROOT and MSYSROOT2, or neither"
#endif
#else
-#ifdef MSYSROOT
+#ifdef MSYSROOT2
#error "Need to define both MSYSROOT and MSYSROOT2, or neither"
#endif
#if defined(__MSYS__) && defined(__LP64__)
@@ -177,10 +177,11 @@ static const test_data datas[] = {
,{"@/foo/bar@", "@" MSYSROOT2 "/foo/bar@", false}
,{"'@/foo/bar'", "'@/foo/bar'", false}
,{"///foo/bar", "//foo/bar", false}
- ,{".:./", ".:./", false}
- ,{"..:./", "..:./", false}
- ,{"../:./", "../:./", false}
- ,{"../aa/:./", "../aa/:./", false}
+ ,{".:./", ".;.\\", false}
+ ,{"..:./", "..;.\\", false}
+ ,{"../:./", "..\\;.\\", false}
+ ,{"../:./", "..\\;.\\", false}
+ ,{"../aa/:./", "..\\aa\\;.\\", false}
,{"../", "../", false}
,{"/foo/bar/", "" MSYSROOT2 "/foo/bar/", false}
,{"-MExtUtils::ParseXS=process_file", "-MExtUtils::ParseXS=process_file", false}
@@ -236,6 +237,12 @@ static const test_data datas[] = {
{".:/tmp/", ".;" MSYSROOT "\\tmp\\", false},
{"..:/tmp/", "..;" MSYSROOT "\\tmp\\", false},
{".:..:/tmp/", ".;..;" MSYSROOT "\\tmp\\", false},
+ {"/this:./there", MSYSROOT "\\this;.\\there", false},
+ {"..:.:./this:/there", "..;.;.\\this;" MSYSROOT "\\there", false},
+ {"--dir=/this:./there", "--dir=" MSYSROOT "\\this;.\\there", false},
+ {"--dir=./this:./there", "--dir=.\\this;.\\there", false},
+ {"WEBINPUTS=.:../../../texk/web2c", "WEBINPUTS=.;..\\..\\..\\texk\\web2c", false},
+ {".:../../../texk/web2c", ".;..\\..\\..\\texk\\web2c", false},
{"/:/tmp/", MSYSROOT "\\;" MSYSROOT "\\tmp\\", false},
{0, 0, false}
};
@@ -280,6 +287,7 @@ int main() {
int passed = 0;
int total = 0;
for ( const test_data *it = &datas[0]; it && it->src; ++it ) {
+ printf("---\n");
total += 1;
const char *path = it->src;
const size_t blen = strlen(it->dst)*2 + 10;
diff --git a/runtime/path_convert/src/path_conv.cpp b/runtime/path_convert/src/path_conv.cpp
index e5206f4..7169ab6 100644
--- a/runtime/path_convert/src/path_conv.cpp
+++ b/runtime/path_convert/src/path_conv.cpp
@@ -269,7 +269,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);
+ debug_printf("found type %d for path %s\n", type, copy_from);
if (type == POSIX_PATH_LIST) {
find_end_of_posix_list(to, in_string);
@@ -389,6 +389,40 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en
return NONE;
}
+ /*
+ * Discern between Git's `:`, SCP's `:` pattern
+ * (which is not a path list but may naively look like one) on the one
+ * hand, and path lists starting with `/`, `./` or `../`
+ * on the other hand.
+ */
+ bool potential_path_list = *it == '/' ||
+ (*it == '.' &&
+ (it + 1 == end || it[1] == '\0' || it[1] == ':' || it[1] == '/' ||
+ (it[1] == '.' &&
+ (it + 2 == end || it[2] == '\0' || it[2] == ':' || it[2] == '/'))));
+
+ /*
+ * Determine if assignment to an environment variable takes place (and
+ * skip Git/SCP handling if so)
+ */
+ bool potential_command_scope_env = false;
+ if (isalpha(*it) || *it == '_' || *it == '-') {
+ ++it;
+
+ if (it != end) {
+ if (*it == '-')
+ ++it;
+
+ while (it != end && *it && (isalnum(*it) || *it == '_')) {
+ ++it;
+ }
+
+ if (*it == '=')
+ potential_command_scope_env = true;
+ }
+ it = *src;
+ }
+
/*
* Prevent Git's :file.txt and :/message syntax from beeing modified.
*/
@@ -414,7 +448,7 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en
goto skip_p2w;
// Leave Git's :./name syntax alone
- if (it + 1 < end && it[1] == '.') {
+ if (!potential_path_list && !potential_command_scope_env && it + 1 < end && it[1] == '.') {
if (it + 2 < end && it[2] == '/')
goto skip_p2w;
if (it + 3 < end && it[2] == '.' && it[3] == '/')