3 exec env LC_CTYPE=iso-8859-1 python "$0" ${1+"$@"}
6 from __future__ import absolute_import, print_function
9 py_maj = sys.version_info[0]
13 byte_stream = lambda x: x.buffer
14 from os import fsencode
16 byte_stream = lambda x: x
17 fsencode = lambda x: x
19 parser = argparse.ArgumentParser()
20 parser.add_argument('-l', nargs=2, metavar=('ORIG', 'NEW'), action='append',
21 help='literally replace ORIG with NEW')
22 opt = parser.parse_args()
25 with byte_stream(sys.stdin) as stdin:
26 content = stdin.read()
27 for orig, new in opt.l:
28 content = content.replace(fsencode(orig), fsencode(new))
29 byte_stream(sys.stdout).write(content)