Repository: conan-io/conan

Issue:
Conan replaces backslashes with forward slashes in env_info variable in activate.bat
Conan replaces all backslashes with forward slashes in activate.bat (and activate.ps1 and activate.sh). This means that to use a variable to pass the path to an executable, we have to manually convert the forward slashes back to backslashes.

I am using Conan 1.8.4 on Windows on Python 3.6. I have created a conanfile.py which contains the following:
```python
from conans import ConanFile
import os.path

class TestPkgConan(ConanFile):
    name = "TestPkg"
    version = "0.0.1"
    description = "A test package"
    settings = "os", "arch"

    def package_info(self):
        self.env_info.testpkg_root = self.package_folder
        self.env_info.testpkg_normalized = os.path.normpath(self.package_folder)
        self.env_info.testpkg_test = 'AC\\DC'
```
and I get the following activate.bat from the virtualenv generator
```cmd
@echo off
SET PROMPT=(conanenv) %PROMPT%
SET testpkg_root=C:/.conan/data/TestPkg/0.0.1/adam/testing/package/ca33edce272a279b24f87dc0d4cf5bbdcffbc187
SET testpkg_normalized=C:/.conan/data/TestPkg/0.0.1/adam/testing/package/ca33edce272a279b24f87dc0d4cf5bbdcffbc187
SET testpkg_test=AC/DC

```
I would expect the environment variable to be set verbatim to the value I chose. And the job of doing path separator conversion to be the packagers, however given that conan seems to do path separator conversion I would at least expect it to output windows native paths for files which are supposed to be consumed by Windows native tools, i.e. activate.bat and activate.ps1.


Discussion:

Resolving patch:
diff --git a/conans/client/loader.py b/conans/client/loader.py
--- a/conans/client/loader.py
+++ b/conans/client/loader.py
@@ -31,7 +31,6 @@ def __init__(self, settings=None, profile=None, create_reference=None):
         self._package_settings = profile.package_settings_values
         self._env_values = profile.env_values
         # Make sure the paths are normalized first, so env_values can be just a copy
-        self._env_values.normalize_paths()
         self._dev_reference = create_reference
 
 
diff --git a/conans/model/env_info.py b/conans/model/env_info.py
--- a/conans/model/env_info.py
+++ b/conans/model/env_info.py
@@ -73,9 +73,9 @@ def append_vars(pairs, result):
                 if isinstance(value, list):
                     value = "[%s]" % ",".join(value)
                 if package:
-                    result.append("%s:%s=%s" % (package, name, value.replace("\\", "/")))
+                    result.append("%s:%s=%s" % (package, name, value))
                 else:
-                    result.append("%s=%s" % (name, value.replace("\\", "/")))
+                    result.append("%s=%s" % (name, value))
 
         result = []
         # First the global vars
@@ -102,10 +102,7 @@ def _sorted_data(self):
     def add(self, name, value, package=None):
         # New data, not previous value
         if name not in self._data[package]:
-            if isinstance(value, list):
-                self._data[package][name] = value
-            else:
-                self._data[package][name] = value.replace("\\", "/")
+            self._data[package][name] = value
         # There is data already
         else:
             # Only append at the end if we had a list
@@ -128,12 +125,6 @@ def update_replace(self, key, value):
             package_name, key = None, key
         self._data[package_name][key] = value
 
-    def normalize_paths(self):
-        for package_name, env_vars in self._data.items():
-            for name, value in env_vars.items():
-                if not isinstance(value, list):
-                    self._data[package_name][name] = value.replace("\\", "/")
-
     def update(self, env_obj):
         """accepts other EnvValues object or DepsEnvInfo
            it prioritize the values that are already at self._data


Test patch:
diff --git a/conans/test/generators/virtualenv_test.py b/conans/test/generators/virtualenv_test.py
--- a/conans/test/generators/virtualenv_test.py
+++ b/conans/test/generators/virtualenv_test.py
@@ -28,6 +28,7 @@ def package_info(self):
         self.env_info.SPECIAL_VAR = "baseValue"
         self.env_info.BASE_LIST = ["baseValue1", "baseValue2"]
         self.env_info.CPPFLAGS = ["-baseFlag1", "-baseFlag2"]
+        self.env_info.BCKW_SLASH = r"base\\value"
 """
 
         dep2 = """
@@ -45,6 +46,7 @@ def package_info(self):
         self.env_info.SPECIAL_VAR = "dummyValue"
         self.env_info.BASE_LIST = ["dummyValue1", "dummyValue2"]
         self.env_info.CPPFLAGS = ["-flag1", "-flag2"]
+        self.env_info.BCKW_SLASH = r"dummy\\value"
 """
         base = '''
 [requires]
@@ -68,6 +70,7 @@ def package_info(self):
             self.assertIn('SET LD_LIBRARY_PATH=dummydir\\lib;basedir\\lib;%LD_LIBRARY_PATH%', activate)
             self.assertIn('SET PATH=dummydir\\bin;basedir\\bin;samebin;%PATH%', activate)
             self.assertIn('SET SPECIAL_VAR=dummyValue', activate)
+            self.assertIn('SET BCKW_SLASH=dummy\\value', activate)
 
             activate = load(os.path.join(client.current_folder, "activate.ps1"))
             self.assertIn('$env:BASE_LIST = "dummyValue1;dummyValue2;baseValue1;baseValue2;$env:BASE_LIST"', activate)
@@ -76,6 +79,7 @@ def package_info(self):
             self.assertIn('$env:LD_LIBRARY_PATH = "dummydir\\lib;basedir\\lib;$env:LD_LIBRARY_PATH"', activate)
             self.assertIn('$env:PATH = "dummydir\\bin;basedir\\bin;samebin;$env:PATH"', activate)
             self.assertIn('$env:SPECIAL_VAR = "dummyValue"', activate)
+            self.assertIn('$env:BCKW_SLASH = "dummy\\value"', activate)
 
             deactivate = load(os.path.join(client.current_folder, "deactivate.bat"))
             self.assertIn('SET PROMPT=%s' % env.setdefault('PROMPT', ''), deactivate)
@@ -85,6 +89,7 @@ def package_info(self):
             self.assertIn('SET LD_LIBRARY_PATH=%s' % env.setdefault('LD_LIBRARY_PATH', ''), deactivate)
             self.assertIn('SET PATH=%s' % env.setdefault('PATH', ''), deactivate)
             self.assertIn('SET SPECIAL_VAR=%s' % env.setdefault('SPECIAL_VAR', ''), deactivate)
+            self.assertIn('SET BCKW_SLASH=%s' % env.setdefault('BCKW_SLASH', ''), deactivate)
 
             deactivate = load(os.path.join(client.current_folder, "deactivate.ps1"))
             self.assertIn('$env:BASE_LIST = "%s"' % env.setdefault('BASE_LIST', ''), deactivate)
@@ -93,6 +98,7 @@ def package_info(self):
             self.assertIn('$env:LD_LIBRARY_PATH = "%s"' % env.setdefault('LD_LIBRARY_PATH', ''), deactivate)
             self.assertIn('$env:PATH = "%s"' % env.setdefault('PATH', ''), deactivate)
             self.assertIn('$env:SPECIAL_VAR = "%s"' % env.setdefault('SPECIAL_VAR', ''), deactivate)
+            self.assertIn('$env:BCKW_SLASH = "%s"' % env.setdefault('BCKW_SLASH', ''), deactivate)
 
         activate = load(os.path.join(client.current_folder, "activate.sh"))
         self.assertIn('OLD_PS1="$PS1"', activate)
@@ -107,6 +113,8 @@ def package_info(self):
         self.assertIn('export CPPFLAGS', activate)
         self.assertIn('SPECIAL_VAR="dummyValue"', activate)
         self.assertIn('export SPECIAL_VAR', activate)
+        self.assertIn('BCKW_SLASH="dummy\\value"', activate)
+        self.assertIn('export BCKW_SLASH', activate)
         if os_info.is_windows:
             self.assertIn('LD_LIBRARY_PATH="dummydir\\lib":"basedir\\lib":$LD_LIBRARY_PATH', activate)
             self.assertIn('PATH="dummydir\\bin":"basedir\\bin":"samebin":$PATH', activate)
@@ -126,6 +134,7 @@ def package_info(self):
             self.assertIn('PATH="%s"' % env.setdefault('PATH', ''), deactivate)
             self.assertIn('export PATH', deactivate)
             self.assertIn('unset SPECIAL_VAR', deactivate)
+            self.assertIn('unset BCKW_SLASH', deactivate)
         else:
             self.assertIn('OLD_PS1="%s"' % env.setdefault('OLD_PS1', ''), deactivate)
             self.assertIn('PS1=$OLD_PS1', deactivate)
@@ -144,6 +153,8 @@ def package_info(self):
             self.assertIn('export PATH', deactivate)
             self.assertIn('SPECIAL_VAR="%s"' % env.setdefault('SPECIAL_VAR', ''), deactivate)
             self.assertIn('export SPECIAL_VAR', deactivate)
+            self.assertIn('BCKW_SLASH="%s"' % env.setdefault('BCKW_SLASH', ''), deactivate)
+            self.assertIn('export BCKW_SLASH', deactivate)
 
     def environment_test(self):
         env = {"PROMPT": "old_PROMPT",
@@ -153,6 +164,7 @@ def environment_test(self):
                "BASE_VAR": "old_BASE_VAR",
                "CPPFLAGS": "old_CPPFLAGS",
                "LD_LIBRARY_PATH": "old_LD_LIBRARY_PATH",
-               "SPECIAL_VAR": "old_SPECIAL_VAR"}
+               "SPECIAL_VAR": "old_SPECIAL_VAR",
+               "BCKW_SLASH": "old_BCKW_SLASH"}
         with tools.environment_append(env):
             self.basic_test(posix_empty_vars=False)