We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Windows: Large number of files causes `xargs: ... Bad file number`
Originally here: https://github.com/pre-commit/pre-commit-hooks/issues/41


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pre_commit/languages/helpers.py`
Content:
```
1 from __future__ import unicode_literals
2 
3 import pipes
4 
5 
6 def file_args_to_stdin(file_args):
7     return '\0'.join(list(file_args) + [''])
8 
9 
10 def run_hook(env, hook, file_args):
11     quoted_args = [pipes.quote(arg) for arg in hook['args']]
12     return env.run(
13         ' '.join(['xargs', '-0', hook['entry']] + quoted_args),
14         stdin=file_args_to_stdin(file_args),
15         retcode=None,
16     )
17 
18 
19 class Environment(object):
20     def __init__(self, repo_cmd_runner):
21         self.repo_cmd_runner = repo_cmd_runner
22 
23     @property
24     def env_prefix(self):
25         """env_prefix is a value that is prefixed to the command that is run.
26 
27         Usually this is to source a virtualenv, etc.
28 
29         Commands basically end up looking like:
30 
31         bash -c '{env_prefix} {cmd}'
32 
33         so you'll often want to end your prefix with &&
34         """
35         raise NotImplementedError
36 
37     def run(self, cmd, **kwargs):
38         """Returns (returncode, stdout, stderr)."""
39         return self.repo_cmd_runner.run(
40             ['bash', '-c', ' '.join([self.env_prefix, cmd])], **kwargs
41         )
42
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pre_commit/languages/helpers.py b/pre_commit/languages/helpers.py
--- a/pre_commit/languages/helpers.py
+++ b/pre_commit/languages/helpers.py
@@ -10,7 +10,9 @@
 def run_hook(env, hook, file_args):
     quoted_args = [pipes.quote(arg) for arg in hook['args']]
     return env.run(
-        ' '.join(['xargs', '-0', hook['entry']] + quoted_args),
+        # Use -s 4000 (slightly less than posix mandated minimum)
+        # This is to prevent "xargs: ... Bad file number" on windows
+        ' '.join(['xargs', '-0', '-s4000', hook['entry']] + quoted_args),
         stdin=file_args_to_stdin(file_args),
         retcode=None,
     )

{"golden_diff": "diff --git a/pre_commit/languages/helpers.py b/pre_commit/languages/helpers.py\n--- a/pre_commit/languages/helpers.py\n+++ b/pre_commit/languages/helpers.py\n@@ -10,7 +10,9 @@\n def run_hook(env, hook, file_args):\n     quoted_args = [pipes.quote(arg) for arg in hook['args']]\n     return env.run(\n-        ' '.join(['xargs', '-0', hook['entry']] + quoted_args),\n+        # Use -s 4000 (slightly less than posix mandated minimum)\n+        # This is to prevent \"xargs: ... Bad file number\" on windows\n+        ' '.join(['xargs', '-0', '-s4000', hook['entry']] + quoted_args),\n         stdin=file_args_to_stdin(file_args),\n         retcode=None,\n     )\n", "issue": "Windows: Large number of files causes `xargs: ... Bad file number`\nOriginally here: https://github.com/pre-commit/pre-commit-hooks/issues/41\n\n", "before_files": [{"content": "from __future__ import unicode_literals\n\nimport pipes\n\n\ndef file_args_to_stdin(file_args):\n    return '\\0'.join(list(file_args) + [''])\n\n\ndef run_hook(env, hook, file_args):\n    quoted_args = [pipes.quote(arg) for arg in hook['args']]\n    return env.run(\n        ' '.join(['xargs', '-0', hook['entry']] + quoted_args),\n        stdin=file_args_to_stdin(file_args),\n        retcode=None,\n    )\n\n\nclass Environment(object):\n    def __init__(self, repo_cmd_runner):\n        self.repo_cmd_runner = repo_cmd_runner\n\n    @property\n    def env_prefix(self):\n        \"\"\"env_prefix is a value that is prefixed to the command that is run.\n\n        Usually this is to source a virtualenv, etc.\n\n        Commands basically end up looking like:\n\n        bash -c '{env_prefix} {cmd}'\n\n        so you'll often want to end your prefix with &&\n        \"\"\"\n        raise NotImplementedError\n\n    def run(self, cmd, **kwargs):\n        \"\"\"Returns (returncode, stdout, stderr).\"\"\"\n        return self.repo_cmd_runner.run(\n            ['bash', '-c', ' '.join([self.env_prefix, cmd])], **kwargs\n        )\n", "path": "pre_commit/languages/helpers.py"}], "after_files": [{"content": "from __future__ import unicode_literals\n\nimport pipes\n\n\ndef file_args_to_stdin(file_args):\n    return '\\0'.join(list(file_args) + [''])\n\n\ndef run_hook(env, hook, file_args):\n    quoted_args = [pipes.quote(arg) for arg in hook['args']]\n    return env.run(\n        # Use -s 4000 (slightly less than posix mandated minimum)\n        # This is to prevent \"xargs: ... Bad file number\" on windows\n        ' '.join(['xargs', '-0', '-s4000', hook['entry']] + quoted_args),\n        stdin=file_args_to_stdin(file_args),\n        retcode=None,\n    )\n\n\nclass Environment(object):\n    def __init__(self, repo_cmd_runner):\n        self.repo_cmd_runner = repo_cmd_runner\n\n    @property\n    def env_prefix(self):\n        \"\"\"env_prefix is a value that is prefixed to the command that is run.\n\n        Usually this is to source a virtualenv, etc.\n\n        Commands basically end up looking like:\n\n        bash -c '{env_prefix} {cmd}'\n\n        so you'll often want to end your prefix with &&\n        \"\"\"\n        raise NotImplementedError\n\n    def run(self, cmd, **kwargs):\n        \"\"\"Returns (returncode, stdout, stderr).\"\"\"\n        return self.repo_cmd_runner.run(\n            ['bash', '-c', ' '.join([self.env_prefix, cmd])], **kwargs\n        )\n", "path": "pre_commit/languages/helpers.py"}]}