diff --git a/CHANGELOG.md b/CHANGELOG.md
index 12ad2d1..ec27cfb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,8 @@ The format mostly follows [Keep a Changelog](http://keepachangelog.com/en/1.0.0/
 - Unit tests have been migrated from `nose` to `pytest`
   and moved from `test/` to `lib/urlwatch/tests/`
 - The ``css`` and ``xpath`` filters now accept ``skip`` and ``maxitems`` as subfilter
+- The ``shellpipe`` filter now inherits all environment variables (e.g. ``$PATH``)
+  of the ``urlwatch`` process
 
 ### Fixed
 
diff --git a/lib/urlwatch/filters.py b/lib/urlwatch/filters.py
index 390ac09..b11a3bb 100644
--- a/lib/urlwatch/filters.py
+++ b/lib/urlwatch/filters.py
@@ -788,10 +788,12 @@ class ShellPipeFilter(FilterBase):
 
         encoding = sys.getdefaultencoding()
 
-        env = {
+        # Work on a copy to not modify the outside environment
+        env = dict(os.environ)
+        env.update({
             'URLWATCH_JOB_NAME': self.job.pretty_name() if self.job else '',
             'URLWATCH_JOB_LOCATION': self.job.get_location() if self.job else '',
-        }
+        })
 
         return subprocess.check_output(subfilter['command'], shell=True,
                                        input=data.encode(encoding), env=env).decode(encoding)

diff --git a/lib/urlwatch/tests/test_filters.py b/lib/urlwatch/tests/test_filters.py
index 80465f3..ca85120 100644
--- a/lib/urlwatch/tests/test_filters.py
+++ b/lib/urlwatch/tests/test_filters.py
@@ -71,3 +71,20 @@ def test_providing_subfilter_to_filter_without_subfilter_raises_valueerror():
 def test_providing_unknown_subfilter_raises_valueerror():
     with pytest.raises(ValueError):
         list(FilterBase.normalize_filter_list([{'grep': {'re': 'Price: .*', 'anothersubfilter': '42'}}]))
+
+
+def test_shellpipe_inherits_environment_but_does_not_modify_it():
+    # https://github.com/thp/urlwatch/issues/541
+
+    # Set a specific value to check it doesn't overwrite the current env
+    os.environ['URLWATCH_JOB_NAME'] = 'should-not-be-overwritten'
+
+    # See if the shellpipe process can use a variable from the outside
+    os.environ['INHERITED_FROM'] = 'parent-process'
+    filtercls = FilterBase.__subclasses__.get('shellpipe')
+    result = filtercls(None, None).filter('input-string', {'command': 'echo "$INHERITED_FROM/$URLWATCH_JOB_NAME"'})
+    # Check that the inherited value and the job name is set properly
+    assert result == 'parent-process/\n'
+
+    # Check that outside the variable wasn't overwritten by the filter
+    assert os.environ['URLWATCH_JOB_NAME'] == 'should-not-be-overwritten'

The shellpipe filter is removing all environment variables
The shellpipe filter is removing all environment variables, then adding 
URLWATCH_JOB_NAME and URLWATCH_JOB_LOCATION. I believe
the code in filters.py should just be adding them to the existing environment.

As a result (simple example shown below), the "sh" that's forked can run
programs in  system directories only because of fallback path-search behavior.
Under Debian, where /bin/sh is a symlink to /bin/dash, an strace shows that
"sh" searches /usr/local/{s,}bin /usr/{s,}bin} and /{s,}bin.

urlwatch fails to find the shellpipe command when it's in ~/bin and isn't
specified with its pathname.

Specifying a "diff_tool" does find the command if it's in my ~/bin
and doesn't empty the environment.

I'm using v2.19 as installed by "pip3" (not the latest code on Github,
though the env. handling appears to be the same).


        % env | grep PATH
        PATH=/home/stosh/bin:/usr/local/bin:/usr/bin:/bin
        % cat date_cat.yaml
        name: watchdog-cat
        command: "date"
        filter:
           - shellpipe: "env >/dev/tty; cat"
        % cat date_mycat.yaml 
        name: watchdog-mycat
        command: "date"
        filter:
           - shellpipe: "env >/dev/tty; mycat"
        % cmp /bin/cat ~/bin/mycat
        % urlwatch --cache date.db --config ~/.config/urlwatch/urlwatch_orig.yaml --urls date_cat.yaml
        URLWATCH_JOB_NAME=watchdog-cat
        URLWATCH_JOB_LOCATION=date
        PWD=/home/stosh
        ===========================================================================
        01. CHANGED: watchdog-cat
        ===========================================================================
        
        ---------------------------------------------------------------------------
        CHANGED: watchdog-cat ( date )
        ---------------------------------------------------------------------------
        --- @	Tue, 28 Jul 2020 17:55:41 -0400
        +++ @	Tue, 28 Jul 2020 17:56:27 -0400
        @@ -1 +1 @@
        -Tue Jul 28 17:55:41 EDT 2020
        +Tue Jul 28 17:56:27 EDT 2020
        
        ---------------------------------------------------------------------------
        
        
        -- 
        urlwatch 2.19, Copyright 2008-2020 Thomas Perl
        Website: https://thp.io/2008/urlwatch/
        watched 1 URLs in 0 seconds
        
        % urlwatch --cache date.db --config ~/.config/urlwatch/urlwatch_orig.yaml --urls date_mycat.yaml
        URLWATCH_JOB_NAME=watchdog-mycat
        URLWATCH_JOB_LOCATION=date
        PWD=/home/stosh
        /bin/sh: 1: mycat: not found
        ===========================================================================
        01. ERROR: watchdog-mycat
        ===========================================================================
        
        ---------------------------------------------------------------------------
        ERROR: watchdog-mycat ( date )
        ---------------------------------------------------------------------------
        Traceback (most recent call last):
          File "/home/stosh/.local/lib/python3.7/site-packages/urlwatch/handler.py", line 92, in process
            data = FilterBase.process(filter_kind, subfilter, self, data)
          File "/home/stosh/.local/lib/python3.7/site-packages/urlwatch/filters.py", line 145, in process
            return filtercls(state.job, state).filter(data, subfilter)
          File "/home/stosh/.local/lib/python3.7/site-packages/urlwatch/filters.py", line 784, in filter
            input=data.encode(encoding), env=env).decode(encoding)
          File "/usr/lib/python3.7/subprocess.py", line 395, in check_output
            **kwargs).stdout
          File "/usr/lib/python3.7/subprocess.py", line 487, in run
            output=stdout, stderr=stderr)
        subprocess.CalledProcessError: Command 'env >/dev/tty; mycat' returned non-zero exit status 127.
        ---------------------------------------------------------------------------
        
        
        -- 
        urlwatch 2.19, Copyright 2008-2020 Thomas Perl
        Website: https://thp.io/2008/urlwatch/
        watched 1 URLs in 0 seconds
 



lib/urlwatch/tests/test_filters.py::test_shellpipe_inherits_environment_but_does_not_modify_it
lib/urlwatch/tests/test_filters.py::test_normalize_filter_list[grep-output0] lib/urlwatch/tests/test_filters.py::test_normalize_filter_list[grep:foo-output1] lib/urlwatch/tests/test_filters.py::test_normalize_filter_list[beautify,grep:foo,html2text-output2] lib/urlwatch/tests/test_filters.py::test_normalize_filter_list[re.sub:.*-output3] lib/urlwatch/tests/test_filters.py::test_normalize_filter_list[re.sub-output4] lib/urlwatch/tests/test_filters.py::test_normalize_filter_list[input5-output5] lib/urlwatch/tests/test_filters.py::test_normalize_filter_list[input6-output6] lib/urlwatch/tests/test_filters.py::test_normalize_filter_list[input7-output7] lib/urlwatch/tests/test_filters.py::test_normalize_filter_list[input8-output8] lib/urlwatch/tests/test_filters.py::test_normalize_filter_list[input9-output9] lib/urlwatch/tests/test_filters.py::test_normalize_filter_list[input10-output10] lib/urlwatch/tests/test_filters.py::test_filters[element_by_tag-test_data0] lib/urlwatch/tests/test_filters.py::test_filters[element_by_tag_nested-test_data1] lib/urlwatch/tests/test_filters.py::test_filters[element_by_id-test_data2] lib/urlwatch/tests/test_filters.py::test_filters[element_by_class-test_data3] lib/urlwatch/tests/test_filters.py::test_filters[xpath_elements-test_data4] lib/urlwatch/tests/test_filters.py::test_filters[xpath_text-test_data5] lib/urlwatch/tests/test_filters.py::test_filters[xpath_exclude-test_data6] lib/urlwatch/tests/test_filters.py::test_filters[xpath_xml_namespaces-test_data7] lib/urlwatch/tests/test_filters.py::test_filters[grep-test_data11] lib/urlwatch/tests/test_filters.py::test_filters[grep_with_comma-test_data12] lib/urlwatch/tests/test_filters.py::test_filters[json_format-test_data13] lib/urlwatch/tests/test_filters.py::test_filters[json_format_subfilter-test_data14] lib/urlwatch/tests/test_filters.py::test_filters[sha1-test_data15] lib/urlwatch/tests/test_filters.py::test_filters[hexdump-test_data16] lib/urlwatch/tests/test_filters.py::test_filters[sort-test_data17] lib/urlwatch/tests/test_filters.py::test_filters[sort_paragraphs-test_data18] lib/urlwatch/tests/test_filters.py::test_filters[sort_separator_reverse-test_data19] lib/urlwatch/tests/test_filters.py::test_filters[sort_reverse-test_data20] lib/urlwatch/tests/test_filters.py::test_filters[reverse_lines-test_data21] lib/urlwatch/tests/test_filters.py::test_filters[reverse_separator_dict-test_data22] lib/urlwatch/tests/test_filters.py::test_filters[reverse_separator_str-test_data23] lib/urlwatch/tests/test_filters.py::test_filters[reverse_separator_paragraph-test_data24] lib/urlwatch/tests/test_filters.py::test_filters[re_sub_multiline-test_data25] lib/urlwatch/tests/test_filters.py::test_invalid_filter_name_raises_valueerror lib/urlwatch/tests/test_filters.py::test_providing_subfilter_to_filter_without_subfilter_raises_valueerror lib/urlwatch/tests/test_filters.py::test_providing_unknown_subfilter_raises_valueerror