I have two python scripts, foo.py and bar.py
foo.py:
#!/usr/bin/env python
os.execv('./bar.py', sys.argv)
bar.py:
#!/usr/bin/env python
print(sys.argv)
When I invoke foo.py
I get the output
['./bar.py']
instead of
['./foo.py']
because the python interpreter is spawned from the shebang and sets argv[0]
to bar.py
, but I want to preserve the name of the original script in argv[0]
.
Is there a way to do that in python?