summaryrefslogtreecommitdiff
path: root/sem_3/SYSTEME/TP5/analyse_options.py
blob: 27c195be2050eee5de41bf6742a532fdd6b994e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python3
import sys
import re
import os
if len(sys.argv) != 2 :
    print("Options incorectes")
os.getenv("HOME")
fd = open("/home/Lenain/.bashrc","r")
content = fd.readlines()
fd.close()
for lines in content :
    if re.search("^-",sys.argv[1]) :
        if re.search("a",sys.argv[1]) :
            opta = re.search("^[\t ]*alias[ \t]*(\w+)=(.+)", lines)
            if opta :
                print(opta.group(1),"=", opta.group(2))
        if re.search("p",sys.argv[1]) :
                opta = re.search("^PATH=$PATH:(.*)", lines)
                if opta :
                    print(opta.group(1))