.. | .. |
---|
65 | 65 | else: |
---|
66 | 66 | print(" %s %s -> %s" % (config, value, new_value)) |
---|
67 | 67 | |
---|
68 | | -def main(): |
---|
| 68 | +def show_diff(): |
---|
69 | 69 | global merge_style |
---|
70 | 70 | |
---|
71 | 71 | # parse command line args |
---|
.. | .. |
---|
129 | 129 | for config in new: |
---|
130 | 130 | print_config("+", config, None, b[config]) |
---|
131 | 131 | |
---|
132 | | -main() |
---|
| 132 | +def main(): |
---|
| 133 | + try: |
---|
| 134 | + show_diff() |
---|
| 135 | + except BrokenPipeError: |
---|
| 136 | + # Python flushes standard streams on exit; redirect remaining output |
---|
| 137 | + # to devnull to avoid another BrokenPipeError at shutdown |
---|
| 138 | + devnull = os.open(os.devnull, os.O_WRONLY) |
---|
| 139 | + os.dup2(devnull, sys.stdout.fileno()) |
---|
| 140 | + sys.exit(1) # Python exits with error code 1 on EPIPE |
---|
| 141 | + |
---|
| 142 | + |
---|
| 143 | +if __name__ == '__main__': |
---|
| 144 | + main() |
---|