diff options
-rw-r--r-- | subcmds/forall.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/subcmds/forall.py b/subcmds/forall.py index 49e725c2..4c1c9ff8 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py | |||
@@ -93,6 +93,9 @@ following <command>. | |||
93 | 93 | ||
94 | Unless -p is used, stdin, stdout, stderr are inherited from the | 94 | Unless -p is used, stdin, stdout, stderr are inherited from the |
95 | terminal and are not redirected. | 95 | terminal and are not redirected. |
96 | |||
97 | If -e is used, when a command exits unsuccessfully, '%prog' will abort | ||
98 | without iterating through the remaining projects. | ||
96 | """ | 99 | """ |
97 | 100 | ||
98 | def _Options(self, p): | 101 | def _Options(self, p): |
@@ -105,6 +108,9 @@ terminal and are not redirected. | |||
105 | dest='command', | 108 | dest='command', |
106 | action='callback', | 109 | action='callback', |
107 | callback=cmd) | 110 | callback=cmd) |
111 | p.add_option('-e', '--abort-on-errors', | ||
112 | dest='abort_on_errors', action='store_true', | ||
113 | help='Abort if a command exits unsuccessfully') | ||
108 | 114 | ||
109 | g = p.add_option_group('Output') | 115 | g = p.add_option_group('Output') |
110 | g.add_option('-p', | 116 | g.add_option('-p', |
@@ -255,7 +261,12 @@ terminal and are not redirected. | |||
255 | s.dest.flush() | 261 | s.dest.flush() |
256 | 262 | ||
257 | r = p.wait() | 263 | r = p.wait() |
258 | if r != 0 and r != rc: | 264 | if r != 0: |
259 | rc = r | 265 | if r != rc: |
266 | rc = r | ||
267 | if opt.abort_on_errors: | ||
268 | print("error: %s: Aborting due to previous error" % project.relpath, | ||
269 | file=sys.stderr) | ||
270 | sys.exit(r) | ||
260 | if rc != 0: | 271 | if rc != 0: |
261 | sys.exit(rc) | 272 | sys.exit(rc) |