You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by mi...@apache.org on 2014/05/08 22:35:51 UTC

[02/10] git commit: cqlsh should return a non-zero error code if a query fails

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


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/8abe9f6f
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/8abe9f6f
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/8abe9f6f

Branch: refs/heads/cassandra-2.0
Commit: 8abe9f6f522146dc478f006a8160b4db1c233169
Parents: d839350
Author: Mikhail Stepura <mi...@apache.org>
Authored: Thu May 8 13:20:35 2014 -0700
Committer: Mikhail Stepura <mi...@apache.org>
Committed: Thu May 8 13:27:41 2014 -0700

----------------------------------------------------------------------
 CHANGES.txt | 1 +
 bin/cqlsh   | 4 ++++
 2 files changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/8abe9f6f/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 312cf06..7021e7b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -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)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8abe9f6f/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index 8e1e0e2..24cb3b8 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -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))