aboutsummaryrefslogtreecommitdiff
path: root/containers/cirrus-run/cirrus-vars.py
blob: 3d863e757868c92ed4edeb5f48eae114e7a7ebd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python3

import os
import re
import sys

var = re.compile(r'@([a-zA-Z0-9_]+)@')


# Return empty string if var is not set, since not all
# OS targets require all vars to be set.
def get_env(matchobj):
    return os.environ.get(matchobj.group(1), '')


for line in sys.stdin:
    print(var.sub(get_env, line), end='')

sys.exit(0)