diff options
Diffstat (limited to 'subcmds/forall.py')
| -rw-r--r-- | subcmds/forall.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/subcmds/forall.py b/subcmds/forall.py index b633b7d4..4c1c9ff8 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | # See the License for the specific language governing permissions and | 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. | 14 | # limitations under the License. |
| 15 | 15 | ||
| 16 | from __future__ import print_function | ||
| 16 | import fcntl | 17 | import fcntl |
| 17 | import re | 18 | import re |
| 18 | import os | 19 | import os |
| @@ -92,6 +93,9 @@ following <command>. | |||
| 92 | 93 | ||
| 93 | Unless -p is used, stdin, stdout, stderr are inherited from the | 94 | Unless -p is used, stdin, stdout, stderr are inherited from the |
| 94 | 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. | ||
| 95 | """ | 99 | """ |
| 96 | 100 | ||
| 97 | def _Options(self, p): | 101 | def _Options(self, p): |
| @@ -104,6 +108,9 @@ terminal and are not redirected. | |||
| 104 | dest='command', | 108 | dest='command', |
| 105 | action='callback', | 109 | action='callback', |
| 106 | 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') | ||
| 107 | 114 | ||
| 108 | g = p.add_option_group('Output') | 115 | g = p.add_option_group('Output') |
| 109 | g.add_option('-p', | 116 | g.add_option('-p', |
| @@ -183,7 +190,7 @@ terminal and are not redirected. | |||
| 183 | if not os.path.exists(cwd): | 190 | if not os.path.exists(cwd): |
| 184 | if (opt.project_header and opt.verbose) \ | 191 | if (opt.project_header and opt.verbose) \ |
| 185 | or not opt.project_header: | 192 | or not opt.project_header: |
| 186 | print >>sys.stderr, 'skipping %s/' % project.relpath | 193 | print('skipping %s/' % project.relpath, file=sys.stderr) |
| 187 | continue | 194 | continue |
| 188 | 195 | ||
| 189 | if opt.project_header: | 196 | if opt.project_header: |
| @@ -254,7 +261,12 @@ terminal and are not redirected. | |||
| 254 | s.dest.flush() | 261 | s.dest.flush() |
| 255 | 262 | ||
| 256 | r = p.wait() | 263 | r = p.wait() |
| 257 | if r != 0 and r != rc: | 264 | if r != 0: |
| 258 | 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) | ||
| 259 | if rc != 0: | 271 | if rc != 0: |
| 260 | sys.exit(rc) | 272 | sys.exit(rc) |
