Skip to content

Instantly share code, notes, and snippets.

@FRex
Created August 21, 2024 19:14
Show Gist options
  • Save FRex/7e93fe0f71580bd5781408fd639d9c1f to your computer and use it in GitHub Desktop.
Save FRex/7e93fe0f71580bd5781408fd639d9c1f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import subprocess
import sys
import os
dirs = os.environ["PATH"].split(os.pathsep)
ourdir = os.path.dirname(__file__)
while dirs[0] != ourdir:
dirs.pop(0)
for d in dirs:
# print(d)
pass
print(sys.argv)
env = os.environ.copy()
env["PATH"] = os.pathsep.join(dirs)
args = list(sys.argv)
args[0] = os.path.basename(sys.argv[0])
result = subprocess.run(args, env=env, check=False)
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment