From 7de842141d3bea4d66f26056bf771a0a6616cb26 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Thu, 1 Apr 2021 15:05:27 +0200 Subject: [PATCH] Install python script, adjusting the shebang --- install-python | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 install-python 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)