On 8/6/19 9:26 PM, Simon Slavin wrote: > Use > > .bail ON > > If the shell bails out because of an error, it should be setting the exit > code to indicate an error.
Except...it's not bailing on the failed import. Does the SQLite shell consider failed dot-commands as errors? $ cat empty.sh #!/bin/sh # Check SQLite version sqlite3 -version # Run supposedly-failing test rm -f empty.db empty.csv echo "" > empty.csv echo "a, b" >> empty.csv sqlite3 empty.db \ '.bail on' \ 'DROP TABLE IF EXISTS empty;' \ '.mode csv' \ 'CREATE TABLE IF NOT EXISTS empty(A, B NOT NULL);' \ '.import empty.csv empty' '.exit' echo "error code is" $? # Check contents of the generated files echo "-----" head empty.csv echo "-----" sqlite3 empty.db .dump echo "-----" $ ./empty.sh 3.28.0 2019-04-16 19:49:53 884b4b7e502b4e991677b53971277adfaf0a04a284f8e483e2553d0f83156b50 empty.csv:1: expected 2 columns but found 1 - filling the rest with NULL empty.csv:1: INSERT failed: NOT NULL constraint failed: empty.B error code is 0 ----- a, b ----- PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE empty(A, B NOT NULL); INSERT INTO empty VALUES('a',' b'); COMMIT; ----- _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users