Repository: conan-io/conan

Issue:
Unexpected behaviour for 'env_reader.get_env'
Behaviour for `env_reader.get_env` ([link](https://github.com/conan-io/conan/blob/e018e0ff0e7f6addf76cf589f471edc23569939d/conans/util/env_reader.py#L12)):

```python
def get_env(env_key, default=None, environment=None):

    if environment is None:
        environment = os.environ

    env_var = environment.get(env_key, default)
    if env_var != default:
        if isinstance(default, str):
            ...
        elif isinstance(default, list):
            return [var.strip() for var in env_var.split(",")]
    return env_var
```

From my point of view the following is unexpected:

```bash
>>> from conans.util.env_reader import get_env
>>> env = {'CONAN_HOOKS': ''}
>>> get_env('CONAN_HOOKS', default=list(), environment=env)
['']
```

IMO, it should return an empty list.

----

I found this making some trials with hooks, once you deactivate all the hooks you have a `conan.conf` file with an empty section:

```ini
[hooks]

```

and then, when executing any command, it gives me the following warning: `WARN: Hook '.py' not found in /Users/jgsogo/.conan/hooks folder. Please remove hook from conan.conf or include it inside the hooks folder.`

So, if you don't consider the previous behavior as unexpected, then an additional check should be added to the `HookManager` to avoid the warning.

cc/ @conan-io/barbarians 

Discussion:

Patch:
diff --git a/conans/util/env_reader.py b/conans/util/env_reader.py
index 05968a930..cbf46174e 100644
--- a/conans/util/env_reader.py
+++ b/conans/util/env_reader.py
@@ -25,5 +25,7 @@ def get_env(env_key, default=None, environment=None):
         elif isinstance(default, float):
             return float(env_var)
         elif isinstance(default, list):
-            return [var.strip() for var in env_var.split(",")]
+            if env_var.strip():
+                return [var.strip() for var in env_var.split(",")]
+            return []
     return env_var


Test patch:
diff --git a/conans/test/unittests/util/env_reader.py b/conans/test/unittests/util/env_reader.py
new file mode 100644
index 000000000..02f273e1c
--- /dev/null
+++ b/conans/test/unittests/util/env_reader.py
@@ -0,0 +1,28 @@
+# coding=utf-8
+
+import unittest
+from unittest import mock
+
+from conans.util.env_reader import get_env
+
+
+class GetEnvTest(unittest.TestCase):
+    environment = {"EMPTY_LIST": "",
+                   "LIST": "a,b,c,d"}
+
+    def test_environment(self):
+        """ Ensure that we are using os.environment if no argument is passed """
+        with mock.patch("os.environ.get", return_value="zzz"):
+            a = get_env("whatever", default=None)
+        self.assertEqual(a, "zzz")
+
+    def test_list_empty(self):
+        r = get_env("EMPTY_LIST", default=list(), environment=self.environment)
+        self.assertEqual(r, [])
+
+        r = get_env("NON-EXISTING-LIST", default=list(), environment=self.environment)
+        self.assertEqual(r, [])
+
+    def test_list(self):
+        r = get_env("LIST", default=list(), environment=self.environment)
+        self.assertEqual(r, ["a", "b", "c", "d"])