Description: Tighten shell code
 * Adapt function declaration to support POSIX shell
 * Avoid globbing and word splitting of arguments passed from outside
Author: Jonas Smedegaard <dr@jones.dk>
Last-Update: 2018-01-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/scripts/dump_sqlite3.sh
+++ b/scripts/dump_sqlite3.sh
@@ -1,21 +1,23 @@
 #!/bin/sh
 
-sqlite3_args=$@
+set -eu
 
-function dump_table {
+dump_table() {
+    set -eu
     table=$1
     columns=$2
+    shift 2
     echo ".mode insert $table
 .output $table.sql
-select $columns from $table;" | sqlite3 $sqlite3_args
+select $columns from $table;" | sqlite3 "$@"
 }
 
-dump_table "roster" "local, remote"
+dump_table "roster" "local, remote" "$@"
 
-dump_table "ircserveroptions_" "id_, owner_, server_, pass_, afterconnectioncommand_, tlsports_, ports_, username_, realname_, verifycert_, trustedfingerprint_, encodingout_, encodingin_, maxhistorylength_"
+dump_table "ircserveroptions_" "id_, owner_, server_, pass_, afterconnectioncommand_, tlsports_, ports_, username_, realname_, verifycert_, trustedfingerprint_, encodingout_, encodingin_, maxhistorylength_" "$@"
 
-dump_table "ircchanneloptions_" "id_, owner_, server_, channel_, encodingout_, encodingin_, maxhistorylength_, persistent_, recordhistory_"
+dump_table "ircchanneloptions_" "id_, owner_, server_, channel_, encodingout_, encodingin_, maxhistorylength_, persistent_, recordhistory_" "$@"
 
-dump_table "globaloptions_" "id_, owner_, maxhistorylength_, recordhistory_, persistent_"
+dump_table "globaloptions_" "id_, owner_, maxhistorylength_, recordhistory_, persistent_" "$@"
 
-dump_table "muclogline_" "id_, uuid_, owner_, ircchanname_, ircservername_, date_, body_, nick_"
+dump_table "muclogline_" "id_, uuid_, owner_, ircchanname_, ircservername_, date_, body_, nick_" "$@"
