xargs.py 388 B

123456789101112131415161718
  1. import sys
  2. import os
  3. import subprocess
  4. if __name__ == '__main__':
  5. pos = sys.argv.index('--')
  6. fname = sys.argv[pos + 1]
  7. cmd = sys.argv[pos + 2 :]
  8. with open(fname, 'r') as f:
  9. args = [x.strip() for x in f]
  10. os.remove(fname)
  11. p = subprocess.Popen(cmd + args, shell=False, stderr=sys.stderr, stdout=sys.stdout)
  12. p.communicate()
  13. sys.exit(p.returncode)