Closed mbucc closed 7 years ago
Output from set -x:
+ ACTION=up
+ shift
++ type -t sqlite3_check
+ [[ function = \f\u\n\c\t\i\o\n ]]
+ sqlite3_check
+ __generic_checker /usr/bin/sqlite3 'select name from sqlite_master where type = '\''table'\'';' 'create table `shmig_version`(version int not null primary key, migrated_at timestamp not null default (datetime(current_timestamp)));'
+ local exe=/usr/bin/sqlite3
+ local 'show=select name from sqlite_master where type = '\''table'\'';'
+ local 'create=create table `shmig_version`(version int not null primary key, migrated_at timestamp not null default (datetime(current_timestamp)));'
+ [[ -x /usr/bin/sqlite3 ]]
+ grep -F -qx shmig_version
+ sqlite3_cli 'select name from sqlite_master where type = '\''table'\'';'
+ local 'args=-bail -batch elmarelli-api.db'
+ [[ 1 -ne 0 ]]
+ /usr/bin/sqlite3 -bail -batch elmarelli-api.db
+ status=("${PIPESTATUS[@]}")
+ local status
+ [[ 141 -ne 0 ]]
+ return 1
+ exit 1
But this worked fine:
$ bash
$ sqlite3 -bail -batch elmarelli-api.db <<< 'select name from sqlite_master where type = '\''table'\'';'
shmig_version
venue
venue_event
fan
fan_event
$
Somehow, this code:
local status=("${PIPESTATUS[@]}")
[[ ${status[0]} -ne 0 ]] && return 1
(ref: https://github.com/mbucc/shmig/blob/e4c58f90d5e8b54dcdb52b32bd696683f542da76/shmig#L169-L171)
produces this output
+ local status
+ [[ 141 -ne 0 ]]
+ return 1