Implement a simplified xargs in python

This commit is contained in:
Anthony Sottile 2016-03-21 19:30:47 -07:00
parent a5b56bd9e3
commit b7d395410b
13 changed files with 130 additions and 62 deletions

View file

@ -12,18 +12,3 @@ def environment_dir(ENVIRONMENT_DIR, language_version):
return None
else:
return '{0}-{1}'.format(ENVIRONMENT_DIR, language_version)
def file_args_to_stdin(file_args):
return '\0'.join(list(file_args) + [''])
def run_hook(cmd_args, file_args):
return cmd_output(
# Use -s 4000 (slightly less than posix mandated minimum)
# This is to prevent "xargs: ... Bad file number" on windows
'xargs', '-0', '-s4000', *cmd_args,
stdin=file_args_to_stdin(file_args),
retcode=None,
encoding=None
)