Dear SQLiters,
I am using sqlite3 shell from bash scripts and I stumbled on what I think is incorrect exit code on error. In the first scenario, on error the exit code is 1 -- expected, in the second it is 0 -- unexpected. The error message is the same in both. Is that normal? echo -e "ww; \n.exit" | sqlite3 Error: near line 1: near "ww": syntax error echo $? 1 echo -e "ww" | sqlite3 Error: near line 1: near "ww": syntax error echo $? 0 Thank you, Roman _______________________________________________ sqlite-users mailing list [hidden email] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users |
Roman. That's a good one. It affects the command status of well formed
SQL as well: sqlite-src-3230000/bld$ echo 'SELECT * FROM sqlite_monster' | ./sqlite3;echo $? Error: near line 1: no such table: sqlite_monster 0 sqlite-src-3230000/bld$ echo 'SELECT * FROM sqlite_monster;' | ./sqlite3;echo $? Error: near line 1: no such table: sqlite_monster 1 Piped SQL lacking a trailing semicolon does indeed cause the shell to report the wrong last command status. Peter On Wed, Apr 4, 2018 at 4:46 PM, Roman Fleysher < [hidden email]> wrote: > Dear SQLiters, > > > I am using sqlite3 shell from bash scripts and I stumbled on what I think > is incorrect exit code on error. In the first scenario, on error the exit > code is 1 -- expected, in the second it is 0 -- unexpected. The error > message is the same in both. Is that normal? > > > echo -e "ww; \n.exit" | sqlite3 > > Error: near line 1: near "ww": syntax error > > echo $? > > 1 > > > echo -e "ww" | sqlite3 > > Error: near line 1: near "ww": syntax error > > echo $? > > 0 > > Thank you, > > Roman > > _______________________________________________ > sqlite-users mailing list > [hidden email] > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > sqlite-users mailing list [hidden email] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users |
In reply to this post by Roman Fleysher
Roman. That's a good one. It affects the command status of well formed
SQL as well: sqlite-src-3230000/bld$ echo 'SELECT * FROM sqlite_monster' | ./sqlite3;echo $? Error: near line 1: no such table: sqlite_monster 0 sqlite-src-3230000/bld$ echo 'SELECT * FROM sqlite_monster;' | ./sqlite3;echo $? Error: near line 1: no such table: sqlite_monster 1 Piped SQL lacking a trailing semicolon does indeed cause the shell to report the wrong last command status. Peter On Wed, Apr 4, 2018 at 4:46 PM, Roman Fleysher < [hidden email]> wrote: > Dear SQLiters, > > > I am using sqlite3 shell from bash scripts and I stumbled on what I think > is incorrect exit code on error. In the first scenario, on error the exit > code is 1 -- expected, in the second it is 0 -- unexpected. The error > message is the same in both. Is that normal? > > > echo -e "ww; \n.exit" | sqlite3 > > Error: near line 1: near "ww": syntax error > > echo $? > > 1 > > > echo -e "ww" | sqlite3 > > Error: near line 1: near "ww": syntax error > > echo $? > > 0 > > Thank you, > > Roman > > _______________________________________________ > sqlite-users mailing list > [hidden email] > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > sqlite-users mailing list [hidden email] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users |
In reply to this post by petern
Thank you, Peter, for confirming. I am using somewhat outdated version.
I think this is a relatively minor issue. It surfaced for me because I mostly use bash shell to access database and rely on error codes to report status. As a work around I now always add ".exit" at the end of the SQL statement. Roman ________________________________________ From: sqlite-users [[hidden email]] on behalf of petern [[hidden email]] Sent: Thursday, April 05, 2018 3:25 AM To: SQLite mailing list Subject: Re: [sqlite] exit status of command shell Roman. That's a good one. It affects the command status of well formed SQL as well: sqlite-src-3230000/bld$ echo 'SELECT * FROM sqlite_monster' | ./sqlite3;echo $? Error: near line 1: no such table: sqlite_monster 0 sqlite-src-3230000/bld$ echo 'SELECT * FROM sqlite_monster;' | ./sqlite3;echo $? Error: near line 1: no such table: sqlite_monster 1 Piped SQL lacking a trailing semicolon does indeed cause the shell to report the wrong last command status. Peter On Wed, Apr 4, 2018 at 4:46 PM, Roman Fleysher < [hidden email]> wrote: > Dear SQLiters, > > > I am using sqlite3 shell from bash scripts and I stumbled on what I think > is incorrect exit code on error. In the first scenario, on error the exit > code is 1 -- expected, in the second it is 0 -- unexpected. The error > message is the same in both. Is that normal? > > > echo -e "ww; \n.exit" | sqlite3 > > Error: near line 1: near "ww": syntax error > > echo $? > > 1 > > > echo -e "ww" | sqlite3 > > Error: near line 1: near "ww": syntax error > > echo $? > > 0 > > Thank you, > > Roman > > _______________________________________________ > sqlite-users mailing list > [hidden email] > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > sqlite-users mailing list [hidden email] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list [hidden email] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users |
Free forum by Nabble | Edit this page |