Add safe path into PATH
This commit is contained in:
18
bin/path-uniq.py
Executable file
18
bin/path-uniq.py
Executable 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")
|
||||||
Reference in New Issue
Block a user