After posting in the SQLite forum, I've got my answers:
"Why is this?" - apparently no real reason, it's "unspecified and untested behavior". It should be fixed in the next release of SQLite, but is not considered a bug and may be reverted later on.
As for a workaround - short of using an updated version of SQLite (as yet unreleased unless building from source), instead of specifying the command as an argument, use echo
and pipe it to sqlite:
$ echo '.tables' | sqlite3 -echo database.db
.tables
stuff
To specify multiple commands, use printf '%s\n'
instead of echo
:
$ printf '%s\n' '.tables' 'SELECT * FROM stuff;' | sqlite3 -echo database.db
.tables
stuff
SELECT * FROM stuff;
apples|67
tissues|10