dotfiles /bin/re-commands

Language Python Lines 27
MD5 Hash 222968d0961f35baea4acd9b2a3c5e75 Estimated Cost $444 (why?)
Repository https://bitbucket.org/flowblok/dotfiles View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python

import os
import re
import sys

checks = []

args = iter(sys.argv[1:])
for regex, command in zip(args, args):
    checks.append((
        re.compile(regex),
        command,
    ))

while True:
#for line in sys.stdin:
    line = sys.stdin.readline()
    if not line:
        break
    line = line[:-1]
    for regex, command in checks:
        if regex.match(line):
            os.system(
                regex.sub(command, line)
            )
Back to Top