Created
December 7, 2017 02:58
-
-
Save kentquirk/9345edbbd972fea31139c45251701e3f to your computer and use it in GitHub Desktop.
fixpath.py is a script to clean up a path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# returns a path with some special front/back values and dups removed | |
import os | |
import sys | |
def getenv(name): | |
try: | |
return os.environ[name].split(':') | |
except KeyError: | |
return [] | |
front=getenv('PATH_FIRST') | |
path =getenv('PATH') | |
back =getenv('PATH_LAST') | |
mypath = [] | |
def additems(bucket): | |
for i in bucket: | |
if i not in mypath: | |
mypath.append(i) | |
additems(front) | |
additems(path) | |
additems(back) | |
sys.stdout.write(':'.join(mypath)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment