cqlsh should return a non-zero error code if a query fails

patch by Branden Visser and Mikhail Stepura; reviewed by Mikhail Stepura for CASSANDRA-6344
This commit is contained in:
Mikhail Stepura 2014-05-08 13:20:35 -07:00
parent d839350f42
commit 8abe9f6f52
2 changed files with 5 additions and 0 deletions

View File

@ -23,6 +23,7 @@
* remove duplicate query for local tokens (CASSANDRA-7182)
* raise streaming phi convict threshold level (CASSANDRA-7063)
* reduce garbage creation in calculatePendingRanges (CASSANDRA-7191)
* exit CQLSH with error status code if script fails (CASSANDRA-6344)
1.2.16
* Add UNLOGGED, COUNTER options to BATCH documentation (CASSANDRA-6816)

View File

@ -548,6 +548,7 @@ class Shell(cmd.Cmd):
self.show_line_nums = True
self.stdin = stdin
self.query_out = sys.stdout
self.statement_error = False
def set_expanded_cql_version(self, ver):
ver, vertuple = full_cql_version(ver)
@ -2175,6 +2176,7 @@ class Shell(cmd.Cmd):
self.query_out.flush()
def printerr(self, text, color=RED, newline=True, shownum=None):
self.statement_error = True
if shownum is None:
shownum = self.show_line_nums
if shownum:
@ -2404,6 +2406,8 @@ def main(options, hostname, port):
shell.cmdloop()
save_history()
if options.file and shell.statement_error:
sys.exit(2)
if __name__ == '__main__':
main(*read_options(sys.argv[1:], os.environ))