diff --git a/CHANGES.txt b/CHANGES.txt index bf31034d0e..5e5a9eea2a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -29,7 +29,7 @@ Merged from 1.2: * Update system.peers correctly when relocating tokens (CASSANDRA-7126) * Add Google Compute Engine snitch (CASSANDRA-7132) * remove duplicate query for local tokens (CASSANDRA-7182) - + * exit CQLSH with error status code if script fails (CASSANDRA-6344) 2.1.0-beta2 * Increase default CL space to 8GB (CASSANDRA-7031) diff --git a/bin/cqlsh b/bin/cqlsh index 3f543da322..ade2f21622 100755 --- a/bin/cqlsh +++ b/bin/cqlsh @@ -520,6 +520,7 @@ class Shell(cmd.Cmd): cassandra.cqltypes.BytesType.deserialize = staticmethod(cassandra.cqltypes.BytesType.validate) cassandra.cqltypes.CassandraType.support_empty_values = True self.empty_lines = 0 + self.statement_error = False def set_expanded_cql_version(self, ver): ver, vertuple = full_cql_version(ver) @@ -1687,6 +1688,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: @@ -1857,6 +1859,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))