Update Makefile to make it compile with recent pilex
[c_to_python.git] / hashline.py
1 #!/usr/bin/env python3
2
3 import sys
4
5 EXIT_SUCCESS = 0
6 EXIT_FAILURE = 1
7
8 if len(sys.argv) < 2:
9   print(f'usage: {sys.argv[0]:s} filename')
10   sys.exit(EXIT_FAILURE)
11 filename = sys.argv[1]
12
13 output = True
14 for line in sys.stdin:
15   if line[:1] == '#':
16     fields = line.split()
17     output = len(fields) >= 3 and fields[2] == f'"{filename:s}"'
18   elif output:
19     sys.stdout.write(line)