[ 
https://issues.apache.org/jira/browse/CASSANDRA-15623?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jordan West updated CASSANDRA-15623:
------------------------------------
     Bug Category: Parent values: Correctness(12982)Level 1 values: API / 
Semantic Definition(13162)
       Complexity: Low Hanging Fruit
    Discovered By: User Report
         Severity: Normal
           Status: Open  (was: Triage Needed)

[~plastikat] thanks for the report. I was able to confirm the behavior you 
mentioned and agree for the stdin case this should be fixed. Do you have time 
to work on a patch? I'd be happy to review. 

Regarding the exit code being 1 or 2, perhaps we should look into that in a 
separate ticket. I see some potential for debate there since {{grep}} for 
example returns 1 when no results are found and 2 when there are syntax errors 
(see man output below).


Piping from STDIN:
{code}
Jordans-MacBook-Pro-2:cassandra jordanwest$ echo 'select * from foo;' | 
./bin/cqlsh
<stdin>:2:InvalidRequest: Error from server: code=2200 [Invalid query] 
message="No keyspace has been specified. USE a keyspace, or explicitly specify 
keyspace.tablename"
Jordans-MacBook-Pro-2:cassandra jordanwest$ echo $?
0
Jordans-MacBook-Pro-2:cassandra jordanwest$ echo 'select * from foo' | 
./bin/cqlsh
<stdin>:2:Incomplete statement at end of file
Jordans-MacBook-Pro-2:cassandra jordanwest$ echo $?
0
{code}


Using {{-e}}:
{code}
Jordans-MacBook-Pro-2:cassandra jordanwest$ ./bin/cqlsh -e 'select * from foo;'
<stdin>:1:InvalidRequest: Error from server: code=2200 [Invalid query] 
message="No keyspace has been specified. USE a keyspace, or explicitly specify 
keyspace.tablename"
Jordans-MacBook-Pro-2:cassandra jordanwest$ echo $?
2
Jordans-MacBook-Pro-2:cassandra jordanwest$ ./bin/cqlsh -e 'select * from;'
<stdin>:1:SyntaxException: line 1:13 no viable alternative at input ';' (select 
* from[;])
Jordans-MacBook-Pro-2:cassandra jordanwest$ echo $?
2
{code}

grep man pages:
{code}
     The grep utility exits with one of the following values:

     0     One or more lines were selected.
     1     No lines were selected.
     >1    An error occurred.
{code}

> When running CQLSH with STDIN input, exit with error status code if script 
> fails
> --------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-15623
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-15623
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Legacy/Tools
>            Reporter: Jacob Becker
>            Priority: Normal
>
> Assuming CASSANDRA-6344 is in place for years and considering that scripts 
> submitted with the `-e` option behave in a similar fashion, it is very 
> surprising that scripts submitted to STDIN (i.e. piped in) always exit with a 
> zero code, regardless of errors. I believe this should be fixed.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to