commit 7de842141d3bea4d66f26056bf771a0a6616cb26 Author: Peter J. Holzer Date: Thu Apr 1 15:05:27 2021 +0200 Install python script, adjusting the shebang diff --git a/install-python b/install-python new file mode 100755 index 0000000..b2fc46a --- /dev/null +++ b/install-python @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 + +import argparse +import shutil +import sys + +ap = argparse.ArgumentParser() +ap.add_argument("source") +ap.add_argument("destination") + +args = ap.parse_args() + +with open(args.source) as inf: + with open(args.destination, "w") as outf: + first_line = inf.readline() + if first_line.startswith("#!"): + print("#!", sys.executable, file=outf) + else: + print("#!", sys.executable, file=outf) + outf.write(first_line) + for line in inf: + outf.write(line) + +shutil.copymode(args.source, args.destination)