Add safe path into PATH

This commit is contained in:
Martin Blazik
2020-09-14 12:14:46 +02:00
parent f09dc48e30
commit 03c3647a32

18
bin/path-uniq.py Executable file
View File

@@ -0,0 +1,18 @@
#!/usr/bin/env python3
import select
import os
from sys import stdin, stdout, argv
if stdin.isatty():
path = os.environ['PATH']
else:
path = stdin.readline()
filtered = []
parts = path.strip().split(':')
parts.extend(argv[1:])
for part in parts:
if part not in filtered:
filtered.append(part)
stdout.write(':'.join(filtered) + "\n")