/ Check-in [09b4f19f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Modified CLI to raise an error when extra command line options are passed. Added tests to verify correct handling, as well as other basic handling of command line options. Ticket [f5cb008a65].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 09b4f19f100fe82a8321b9ded99e679b7eedc1fa
User & Date: shaneh 2009-11-11 04:17:07
References
2009-11-11
04:17 Fixed ticket [f5cb008a]: Shell silently ignores extra parameters plus 3 other changes artifact: e603814c user: shane
Context
2009-11-11
13:17
Allow media sector sizes as small as 32. The former minimum size was 512. check-in: 5a32bfc1 user: drh tags: trunk
04:17
Modified CLI to raise an error when extra command line options are passed. Added tests to verify correct handling, as well as other basic handling of command line options. Ticket [f5cb008a65]. check-in: 09b4f19f user: shaneh tags: trunk
01:14
Additional test cases for the coalesce() and ifnull() functions. check-in: d0591258 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

  3290   3290     return rc;
  3291   3291   }
  3292   3292   
  3293   3293   /*
  3294   3294   ** Show available command line options
  3295   3295   */
  3296   3296   static const char zOptions[] = 
         3297  +  "   -help                show this message\n"
  3297   3298     "   -init filename       read/process named file\n"
  3298   3299     "   -echo                print commands before execution\n"
  3299   3300     "   -[no]header          turn headers on or off\n"
  3300   3301     "   -bail                stop after hitting an error\n"
  3301   3302     "   -interactive         force interactive I/O\n"
  3302   3303     "   -batch               force batch I/O\n"
  3303   3304     "   -column              set output mode to 'column'\n"
................................................................................
  3386   3387       data.zDbFilename = ":memory:";
  3387   3388   #else
  3388   3389       data.zDbFilename = 0;
  3389   3390   #endif
  3390   3391     }
  3391   3392     if( i<argc ){
  3392   3393       zFirstCmd = argv[i++];
         3394  +  }
         3395  +  if( i<argc ){
         3396  +    fprintf(stderr,"%s: Error: too many options: \"%s\"\n", Argv0, argv[i]);
         3397  +    fprintf(stderr,"Use -help for a list of options.\n");
         3398  +    return 1;
  3393   3399     }
  3394   3400     data.out = stdout;
  3395   3401   
  3396   3402   #ifdef SQLITE_OMIT_MEMORYDB
  3397   3403     if( data.zDbFilename==0 ){
  3398   3404       fprintf(stderr,"%s: Error: no database filename specified\n", Argv0);
  3399   3405       return 1;
................................................................................
  3437   3443       }else if( strcmp(z,"-column")==0 ){
  3438   3444         data.mode = MODE_Column;
  3439   3445       }else if( strcmp(z,"-csv")==0 ){
  3440   3446         data.mode = MODE_Csv;
  3441   3447         memcpy(data.separator,",",2);
  3442   3448       }else if( strcmp(z,"-separator")==0 ){
  3443   3449         i++;
         3450  +      if(i>=argc){
         3451  +        fprintf(stderr,"%s: Error: missing argument for option: %s\n", Argv0, z);
         3452  +        fprintf(stderr,"Use -help for a list of options.\n");
         3453  +        return 1;
         3454  +      }
  3444   3455         sqlite3_snprintf(sizeof(data.separator), data.separator,
  3445   3456                          "%.*s",(int)sizeof(data.separator)-1,argv[i]);
  3446   3457       }else if( strcmp(z,"-nullvalue")==0 ){
  3447   3458         i++;
         3459  +      if(i>=argc){
         3460  +        fprintf(stderr,"%s: Error: missing argument for option: %s\n", Argv0, z);
         3461  +        fprintf(stderr,"Use -help for a list of options.\n");
         3462  +        return 1;
         3463  +      }
  3448   3464         sqlite3_snprintf(sizeof(data.nullvalue), data.nullvalue,
  3449   3465                          "%.*s",(int)sizeof(data.nullvalue)-1,argv[i]);
  3450   3466       }else if( strcmp(z,"-header")==0 ){
  3451   3467         data.showHeader = 1;
  3452   3468       }else if( strcmp(z,"-noheader")==0 ){
  3453   3469         data.showHeader = 0;
  3454   3470       }else if( strcmp(z,"-echo")==0 ){

Changes to tool/shell1.test.

    12     12   # The focus of this file is testing the CLI shell tool.
    13     13   #
    14     14   # $Id: shell1.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
    15     15   #
    16     16   
    17     17   # Test plan:
    18     18   #
    19         -#   shell1-1.*: Basic "dot" command token parsing.
    20         -#   shell1-2.*: Basic test that "dot" command can be called.
           19  +#   shell1-1.*: Basic command line option handling.
           20  +#   shell1-2.*: Basic "dot" command token parsing.
           21  +#   shell1-3.*: Basic test that "dot" command can be called.
    21     22   #
    22     23   
    23     24   package require sqlite3
           25  +
           26  +set CLI "./sqlite"
    24     27   
    25     28   proc do_test {name cmd expected} {
    26     29     puts -nonewline "$name ..."
    27     30     set res [uplevel $cmd]
    28     31     if {$res eq $expected} {
    29     32       puts Ok
    30     33     } else {
................................................................................
    40     43   }
    41     44   
    42     45   proc catchsql {sql} {
    43     46     set rc [catch {uplevel [list db eval $sql]} msg]
    44     47     list $rc $msg
    45     48   }
    46     49   
    47         -proc catchcmd {cmd} {
           50  +proc catchcmd {db cmd} {
           51  +  global CLI
    48     52     set out [open cmds.txt w]
    49     53     puts $out $cmd
    50     54     close $out
    51         -  set rc [catch { exec ./sqlite test.db < cmds.txt } msg]
           55  +  set line "exec $CLI $db < cmds.txt"
           56  +  set rc [catch { eval $line } msg]
    52     57     list $rc $msg
    53     58   }
    54     59   
    55     60   file delete -force test.db test.db.journal
    56     61   sqlite3 db test.db
    57     62   
           63  +#----------------------------------------------------------------------------
           64  +# Test cases shell1-1.*: Basic command line option handling.
           65  +#
           66  +
           67  +# invalid option
           68  +do_test shell1-1.1.1 {
           69  +  set res [catchcmd "-bad test.db" ""]
           70  +  set rc [lindex $res 0]
           71  +  list $rc \
           72  +       [regexp {Error: unknown option: -bad} $res]
           73  +} {1 1}
           74  +# error on extra options
           75  +do_test shell1-1.1.2 {
           76  +  set res [catchcmd "-bad test.db \"select 3\" \"select 4\"" ""]
           77  +  set rc [lindex $res 0]
           78  +  list $rc \
           79  +       [regexp {Error: too many options: "select 4"} $res]
           80  +} {1 1}
           81  +# error on extra options
           82  +do_test shell1-1.3.2 {
           83  +  set res [catchcmd "-bad FOO test.db BAD" ".quit"]
           84  +  set rc [lindex $res 0]
           85  +  list $rc \
           86  +       [regexp {Error: too many options: "BAD"} $res]
           87  +} {1 1}
           88  +
           89  +# -help
           90  +do_test shell1-1.2.1 {
           91  +  set res [catchcmd "-help test.db" ""]
           92  +  set rc [lindex $res 0]
           93  +  list $rc \
           94  +       [regexp {Usage} $res] \
           95  +       [regexp {\-init} $res] \
           96  +       [regexp {\-version} $res]
           97  +} {1 1 1 1}
           98  +
           99  +# -init filename       read/process named file
          100  +do_test shell1-1.3.1 {
          101  +  catchcmd "-init FOO test.db" "" 
          102  +} {0 {}}
          103  +do_test shell1-1.3.2 {
          104  +  set res [catchcmd "-init FOO test.db .quit BAD" ""]
          105  +  set rc [lindex $res 0]
          106  +  list $rc \
          107  +       [regexp {Error: too many options: "BAD"} $res]
          108  +} {1 1}
          109  +
          110  +# -echo                print commands before execution
          111  +do_test shell1-1.4.1 {
          112  +  catchcmd "-echo test.db" "" 
          113  +} {0 {}}
          114  +
          115  +# -[no]header          turn headers on or off
          116  +do_test shell1-1.5.1 {
          117  +  catchcmd "-header test.db" "" 
          118  +} {0 {}}
          119  +do_test shell1-1.5.2 {
          120  +  catchcmd "-noheader test.db" "" 
          121  +} {0 {}}
          122  +
          123  +# -bail                stop after hitting an error
          124  +do_test shell1-1.6.1 {
          125  +  catchcmd "-bail test.db" "" 
          126  +} {0 {}}
          127  +
          128  +# -interactive         force interactive I/O
          129  +do_test shell1-1.7.1 {
          130  +  set res [catchcmd "-interactive test.db" ".quit"]
          131  +  set rc [lindex $res 0]
          132  +  list $rc \
          133  +       [regexp {SQLite version} $res] \
          134  +       [regexp {Enter SQL statements} $res]
          135  +} {0 1 1}
          136  +
          137  +# -batch               force batch I/O
          138  +do_test shell1-1.8.1 {
          139  +  catchcmd "-batch test.db" "" 
          140  +} {0 {}}
          141  +
          142  +# -column              set output mode to 'column'
          143  +do_test shell1-1.9.1 {
          144  +  catchcmd "-column test.db" "" 
          145  +} {0 {}}
          146  +
          147  +# -csv                 set output mode to 'csv'
          148  +do_test shell1-1.10.1 {
          149  +  catchcmd "-csv test.db" "" 
          150  +} {0 {}}
          151  +
          152  +# -html                set output mode to HTML
          153  +do_test shell1-1.11.1 {
          154  +  catchcmd "-html test.db" "" 
          155  +} {0 {}}
          156  +
          157  +# -line                set output mode to 'line'
          158  +do_test shell1-1.12.1 {
          159  +  catchcmd "-line test.db" "" 
          160  +} {0 {}}
          161  +
          162  +# -list                set output mode to 'list'
          163  +do_test shell1-1.13.1 {
          164  +  catchcmd "-list test.db" "" 
          165  +} {0 {}}
          166  +
          167  +# -separator 'x'       set output field separator (|)
          168  +do_test shell1-1.14.1 {
          169  +  catchcmd "-separator 'x' test.db" "" 
          170  +} {0 {}}
          171  +do_test shell1-1.14.2 {
          172  +  catchcmd "-separator x test.db" "" 
          173  +} {0 {}}
          174  +do_test shell1-1.14.3 {
          175  +  set res [catchcmd "-separator" ""]
          176  +  set rc [lindex $res 0]
          177  +  list $rc \
          178  +       [regexp {Error: missing argument for option: -separator} $res]
          179  +} {1 1}
          180  +
          181  +# -nullvalue 'text'    set text string for NULL values
          182  +do_test shell1-1.15.1 {
          183  +  catchcmd "-nullvalue 'x' test.db" ""
          184  +} {0 {}}
          185  +do_test shell1-1.15.2 {
          186  +  catchcmd "-nullvalue x test.db" ""
          187  +} {0 {}}
          188  +do_test shell1-1.15.3 {
          189  +  set res [catchcmd "-nullvalue" ""]
          190  +  set rc [lindex $res 0]
          191  +  list $rc \
          192  +       [regexp {Error: missing argument for option: -nullvalue} $res]
          193  +} {1 1}
          194  +
          195  +# -version             show SQLite version
          196  +do_test shell1-1.16.1 {
          197  +  catchcmd "-version test.db" "" 
          198  +} {0 3.6.20}
    58    199   
    59    200   #----------------------------------------------------------------------------
    60         -# Test cases shell1-1.* Basic "dot" command token parsing.
          201  +# Test cases shell1-2.*: Basic "dot" command token parsing.
    61    202   #
    62    203   
    63    204   # check first token handling
    64         -do_test shell1-1.1.1 {
    65         -  catchcmd ".foo"
          205  +do_test shell1-2.1.1 {
          206  +  catchcmd " test.db" ".foo" 
    66    207   } {1 {Error: unknown command or invalid arguments:  "foo". Enter ".help" for help}}
    67         -do_test shell1-1.1.2 {
    68         -  catchcmd ".\"foo OFF\""
          208  +do_test shell1-2.1.2 {
          209  +  catchcmd " test.db" ".\"foo OFF\""
    69    210   } {1 {Error: unknown command or invalid arguments:  "foo OFF". Enter ".help" for help}}
    70         -do_test shell1-1.1.3 {
    71         -  catchcmd ".\'foo OFF\'"
          211  +do_test shell1-2.1.3 {
          212  +  catchcmd " test.db" ".\'foo OFF\'"
    72    213   } {1 {Error: unknown command or invalid arguments:  "foo OFF". Enter ".help" for help}}
    73    214   
    74    215   # unbalanced quotes
    75         -do_test shell1-1.2.1 {
    76         -  catchcmd ".\"foo OFF"
          216  +do_test shell1-2.2.1 {
          217  +  catchcmd " test.db" ".\"foo OFF"
    77    218   } {1 {Error: unknown command or invalid arguments:  "foo OFF". Enter ".help" for help}}
    78         -do_test shell1-1.2.2 {
    79         -  catchcmd ".\'foo OFF"
          219  +do_test shell1-2.2.2 {
          220  +  catchcmd " test.db" ".\'foo OFF"
    80    221   } {1 {Error: unknown command or invalid arguments:  "foo OFF". Enter ".help" for help}}
    81         -do_test shell1-1.2.3 {
    82         -  catchcmd ".explain \"OFF"
          222  +do_test shell1-2.2.3 {
          223  +  catchcmd " test.db" ".explain \"OFF"
    83    224   } {0 {}}
    84         -do_test shell1-1.2.4 {
    85         -  catchcmd ".explain \'OFF"
          225  +do_test shell1-2.2.4 {
          226  +  catchcmd " test.db" ".explain \'OFF"
    86    227   } {0 {}}
    87         -do_test shell1-1.2.5 {
    88         -  catchcmd ".mode \"insert FOO"
          228  +do_test shell1-2.2.5 {
          229  +  catchcmd " test.db" ".mode \"insert FOO"
    89    230   } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
    90         -do_test shell1-1.2.6 {
    91         -  catchcmd ".mode \'insert FOO"
          231  +do_test shell1-2.2.6 {
          232  +  catchcmd " test.db" ".mode \'insert FOO"
    92    233   } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
    93    234   
    94    235   # check multiple tokens, and quoted tokens
    95         -do_test shell1-1.3.1 {
    96         -  catchcmd ".explain 1"
    97         -} {0 {}}
    98         -do_test shell1-1.3.2 {
    99         -  catchcmd ".explain on"
   100         -} {0 {}}
   101         -do_test shell1-1.3.3 {
   102         -  catchcmd ".explain \"1 2 3\""
   103         -} {0 {}}
   104         -do_test shell1-1.3.4 {
   105         -  catchcmd ".explain \"OFF\""
   106         -} {0 {}}
   107         -do_test shell1-1.3.5 {
   108         -  catchcmd ".\'explain\' \'OFF\'"
   109         -} {0 {}}
   110         -do_test shell1-1.3.6 {
   111         -  catchcmd ".explain \'OFF\'"
   112         -} {0 {}}
   113         -do_test shell1-1.3.7 {
   114         -  catchcmd ".\'explain\' \'OFF\'"
          236  +do_test shell1-2.3.1 {
          237  +  catchcmd " test.db" ".explain 1"
          238  +} {0 {}}
          239  +do_test shell1-2.3.2 {
          240  +  catchcmd " test.db" ".explain on"
          241  +} {0 {}}
          242  +do_test shell1-2.3.3 {
          243  +  catchcmd " test.db" ".explain \"1 2 3\""
          244  +} {0 {}}
          245  +do_test shell1-2.3.4 {
          246  +  catchcmd " test.db" ".explain \"OFF\""
          247  +} {0 {}}
          248  +do_test shell1-2.3.5 {
          249  +  catchcmd " test.db" ".\'explain\' \'OFF\'"
          250  +} {0 {}}
          251  +do_test shell1-2.3.6 {
          252  +  catchcmd " test.db" ".explain \'OFF\'"
          253  +} {0 {}}
          254  +do_test shell1-2.3.7 {
          255  +  catchcmd " test.db" ".\'explain\' \'OFF\'"
   115    256   } {0 {}}
   116    257   
   117    258   # check quoted args are unquoted
   118         -do_test shell1-1.4.1 {
   119         -  catchcmd ".mode FOO"
          259  +do_test shell1-2.4.1 {
          260  +  catchcmd " test.db" ".mode FOO"
   120    261   } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
   121         -do_test shell1-1.4.2 {
   122         -  catchcmd ".mode csv"
          262  +do_test shell1-2.4.2 {
          263  +  catchcmd " test.db" ".mode csv"
   123    264   } {0 {}}
   124         -do_test shell1-1.4.2 {
   125         -  catchcmd ".mode \"csv\""
          265  +do_test shell1-2.4.2 {
          266  +  catchcmd " test.db" ".mode \"csv\""
   126    267   } {0 {}}
   127    268   
   128    269   
   129    270   #----------------------------------------------------------------------------
   130         -# Test cases shell1-2.* Basic test that "dot" command can be called.
          271  +# Test cases shell1-3.*: Basic test that "dot" command can be called.
   131    272   #
   132    273   
   133    274   # .backup ?DB? FILE      Backup DB (default "main") to FILE
   134         -do_test shell1-2.1.1 {
   135         -  catchcmd ".backup"
          275  +do_test shell1-3.1.1 {
          276  +  catchcmd " test.db" ".backup"
   136    277   } {1 {Error: unknown command or invalid arguments:  "backup". Enter ".help" for help}}
   137         -do_test shell1-2.1.2 {
   138         -  # catchcmd ".backup FOO"
          278  +do_test shell1-3.1.2 {
          279  +  # catchcmd " test.db" ".backup FOO"
   139    280     #TBD!!! this asserts currently
   140    281   } {}
   141         -do_test shell1-2.1.3 {
   142         -  catchcmd ".backup FOO BAR"
          282  +do_test shell1-3.1.3 {
          283  +  catchcmd " test.db" ".backup FOO BAR"
   143    284   } {1 {Error: unknown database FOO}}
   144         -do_test shell1-2.1.4 {
          285  +do_test shell1-3.1.4 {
   145    286     # too many arguments
   146         -  catchcmd ".backup FOO BAR BAD"
          287  +  catchcmd " test.db" ".backup FOO BAR BAD"
   147    288   } {1 {Error: unknown command or invalid arguments:  "backup". Enter ".help" for help}}
   148    289   
   149    290   # .bail ON|OFF           Stop after hitting an error.  Default OFF
   150         -do_test shell1-2.2.1 {
   151         -  catchcmd ".bail"
          291  +do_test shell1-3.2.1 {
          292  +  catchcmd " test.db" ".bail"
   152    293   } {1 {Error: unknown command or invalid arguments:  "bail". Enter ".help" for help}}
   153         -do_test shell1-2.2.2 {
   154         -  catchcmd ".bail ON"
          294  +do_test shell1-3.2.2 {
          295  +  catchcmd " test.db" ".bail ON"
   155    296   } {0 {}}
   156         -do_test shell1-2.2.3 {
   157         -  catchcmd ".bail OFF"
          297  +do_test shell1-3.2.3 {
          298  +  catchcmd " test.db" ".bail OFF"
   158    299   } {0 {}}
   159         -do_test shell1-2.2.4 {
          300  +do_test shell1-3.2.4 {
   160    301     # too many arguments
   161         -  catchcmd ".bail OFF BAD"
          302  +  catchcmd " test.db" ".bail OFF BAD"
   162    303   } {1 {Error: unknown command or invalid arguments:  "bail". Enter ".help" for help}}
   163    304   
   164    305   # .databases             List names and files of attached databases
   165         -do_test shell1-2.3.1 {
   166         -  set res [catchcmd ".databases"]
          306  +do_test shell1-3.3.1 {
          307  +  set res [catchcmd " test.db" ".databases"]
   167    308     regexp {0.*main.*test\.db} $res
   168    309   } {1}
   169         -do_test shell1-2.3.2 {
          310  +do_test shell1-3.3.2 {
   170    311     # too many arguments
   171         -  catchcmd ".databases BAD"
          312  +  catchcmd " test.db" ".databases BAD"
   172    313   } {1 {Error: unknown command or invalid arguments:  "databases". Enter ".help" for help}}
   173    314   
   174    315   # .dump ?TABLE? ...      Dump the database in an SQL text format
   175    316   #                          If TABLE specified, only dump tables matching
   176    317   #                          LIKE pattern TABLE.
   177         -do_test shell1-2.4.1 {
   178         -  set res [catchcmd ".dump"]
          318  +do_test shell1-3.4.1 {
          319  +  set res [catchcmd " test.db" ".dump"]
   179    320     list [regexp {BEGIN TRANSACTION;} $res] \
   180    321          [regexp {COMMIT;} $res]
   181    322   } {1 1}
   182         -do_test shell1-2.4.2 {
   183         -  set res [catchcmd ".dump FOO"]
          323  +do_test shell1-3.4.2 {
          324  +  set res [catchcmd " test.db" ".dump FOO"]
   184    325     list [regexp {BEGIN TRANSACTION;} $res] \
   185    326          [regexp {COMMIT;} $res]
   186    327   } {1 1}
   187         -do_test shell1-2.4.3 {
          328  +do_test shell1-3.4.3 {
   188    329     # too many arguments
   189         -  catchcmd ".dump FOO BAD"
          330  +  catchcmd " test.db" ".dump FOO BAD"
   190    331   } {1 {Error: unknown command or invalid arguments:  "dump". Enter ".help" for help}}
   191    332   
   192    333   # .echo ON|OFF           Turn command echo on or off
   193         -do_test shell1-2.5.1 {
   194         -  catchcmd ".echo"
          334  +do_test shell1-3.5.1 {
          335  +  catchcmd " test.db" ".echo"
   195    336   } {1 {Error: unknown command or invalid arguments:  "echo". Enter ".help" for help}}
   196         -do_test shell1-2.5.2 {
   197         -  catchcmd ".echo ON"
          337  +do_test shell1-3.5.2 {
          338  +  catchcmd " test.db" ".echo ON"
   198    339   } {0 {}}
   199         -do_test shell1-2.5.3 {
   200         -  catchcmd ".echo OFF"
          340  +do_test shell1-3.5.3 {
          341  +  catchcmd " test.db" ".echo OFF"
   201    342   } {0 {}}
   202         -do_test shell1-2.5.4 {
          343  +do_test shell1-3.5.4 {
   203    344     # too many arguments
   204         -  catchcmd ".echo OFF BAD"
          345  +  catchcmd " test.db" ".echo OFF BAD"
   205    346   } {1 {Error: unknown command or invalid arguments:  "echo". Enter ".help" for help}}
   206    347   
   207    348   # .exit                  Exit this program
   208         -do_test shell1-2.6.1 {
   209         -  catchcmd ".exit"
          349  +do_test shell1-3.6.1 {
          350  +  catchcmd " test.db" ".exit"
   210    351   } {0 {}}
   211         -do_test shell1-2.6.2 {
          352  +do_test shell1-3.6.2 {
   212    353     # too many arguments
   213         -  catchcmd ".exit BAD"
          354  +  catchcmd " test.db" ".exit BAD"
   214    355   } {1 {Error: unknown command or invalid arguments:  "exit". Enter ".help" for help}}
   215    356   
   216    357   # .explain ON|OFF        Turn output mode suitable for EXPLAIN on or off.
   217         -do_test shell1-2.7.1 {
   218         -  catchcmd ".explain"
          358  +do_test shell1-3.7.1 {
          359  +  catchcmd " test.db" ".explain"
   219    360     # explain is the exception to the booleans.  without an option, it turns it on.
   220    361   } {0 {}}
   221         -do_test shell1-2.7.2 {
   222         -  catchcmd ".explain ON"
          362  +do_test shell1-3.7.2 {
          363  +  catchcmd " test.db" ".explain ON"
   223    364   } {0 {}}
   224         -do_test shell1-2.7.3 {
   225         -  catchcmd ".explain OFF"
          365  +do_test shell1-3.7.3 {
          366  +  catchcmd " test.db" ".explain OFF"
   226    367   } {0 {}}
   227         -do_test shell1-2.7.4 {
          368  +do_test shell1-3.7.4 {
   228    369     # too many arguments
   229         -  catchcmd ".explain OFF BAD"
          370  +  catchcmd " test.db" ".explain OFF BAD"
   230    371   } {1 {Error: unknown command or invalid arguments:  "explain". Enter ".help" for help}}
   231    372   
   232    373   # .genfkey ?OPTIONS?     Options are:
   233    374   #                          --no-drop: Do not drop old fkey triggers.
   234    375   #                          --ignore-errors: Ignore tables with fkey errors
   235    376   #                          --exec: Execute generated SQL immediately
   236    377   #                        See file tool/genfkey.README in the source
   237    378   #                        distribution for further information.
   238         -do_test shell1-2.8.1 {
   239         -  catchcmd ".genfkey"
          379  +do_test shell1-3.8.1 {
          380  +  catchcmd " test.db" ".genfkey"
   240    381   } {0 {}}
   241         -do_test shell1-2.8.2 {
   242         -  catchcmd ".genfkey FOO"
          382  +do_test shell1-3.8.2 {
          383  +  catchcmd " test.db" ".genfkey FOO"
   243    384   } {1 {unknown option: FOO}}
   244    385   
   245    386   # .header(s) ON|OFF      Turn display of headers on or off
   246         -do_test shell1-2.9.1 {
   247         -  catchcmd ".header"
          387  +do_test shell1-3.9.1 {
          388  +  catchcmd " test.db" ".header"
   248    389   } {1 {Error: unknown command or invalid arguments:  "header". Enter ".help" for help}}
   249         -do_test shell1-2.9.2 {
   250         -  catchcmd ".header ON"
          390  +do_test shell1-3.9.2 {
          391  +  catchcmd " test.db" ".header ON"
   251    392   } {0 {}}
   252         -do_test shell1-2.9.3 {
   253         -  catchcmd ".header OFF"
          393  +do_test shell1-3.9.3 {
          394  +  catchcmd " test.db" ".header OFF"
   254    395   } {0 {}}
   255         -do_test shell1-2.9.4 {
          396  +do_test shell1-3.9.4 {
   256    397     # too many arguments
   257         -  catchcmd ".header OFF BAD"
          398  +  catchcmd " test.db" ".header OFF BAD"
   258    399   } {1 {Error: unknown command or invalid arguments:  "header". Enter ".help" for help}}
   259    400   
   260         -do_test shell1-2.9.5 {
   261         -  catchcmd ".headers"
          401  +do_test shell1-3.9.5 {
          402  +  catchcmd " test.db" ".headers"
   262    403   } {1 {Error: unknown command or invalid arguments:  "headers". Enter ".help" for help}}
   263         -do_test shell1-2.9.6 {
   264         -  catchcmd ".headers ON"
          404  +do_test shell1-3.9.6 {
          405  +  catchcmd " test.db" ".headers ON"
   265    406   } {0 {}}
   266         -do_test shell1-2.9.7 {
   267         -  catchcmd ".headers OFF"
          407  +do_test shell1-3.9.7 {
          408  +  catchcmd " test.db" ".headers OFF"
   268    409   } {0 {}}
   269         -do_test shell1-2.9.8 {
          410  +do_test shell1-3.9.8 {
   270    411     # too many arguments
   271         -  catchcmd ".headers OFF BAD"
          412  +  catchcmd " test.db" ".headers OFF BAD"
   272    413   } {1 {Error: unknown command or invalid arguments:  "headers". Enter ".help" for help}}
   273    414   
   274    415   # .help                  Show this message
   275         -do_test shell1-2.10.1 {
   276         -  set res [catchcmd ".help"]
          416  +do_test shell1-3.10.1 {
          417  +  set res [catchcmd " test.db" ".help"]
   277    418     # look for a few of the possible help commands
   278    419     list [regexp {.help} $res] \
   279    420          [regexp {.quit} $res] \
   280    421          [regexp {.show} $res]
   281    422   } {1 1 1}
   282         -do_test shell1-2.10.2 {
          423  +do_test shell1-3.10.2 {
   283    424     # we allow .help to take extra args (it is help after all)
   284         -  set res [catchcmd ".help BAD"]
          425  +  set res [catchcmd " test.db" ".help BAD"]
   285    426     # look for a few of the possible help commands
   286    427     list [regexp {.help} $res] \
   287    428          [regexp {.quit} $res] \
   288    429          [regexp {.show} $res]
   289    430   } {1 1 1}
   290    431   
   291    432   # .import FILE TABLE     Import data from FILE into TABLE
   292         -do_test shell1-2.11.1 {
   293         -  catchcmd ".import"
          433  +do_test shell1-3.11.1 {
          434  +  catchcmd " test.db" ".import"
   294    435   } {1 {Error: unknown command or invalid arguments:  "import". Enter ".help" for help}}
   295         -do_test shell1-2.11.2 {
   296         -  catchcmd ".import FOO"
          436  +do_test shell1-3.11.2 {
          437  +  catchcmd " test.db" ".import FOO"
   297    438   } {1 {Error: unknown command or invalid arguments:  "import". Enter ".help" for help}}
   298         -do_test shell1-2.11.2 {
   299         -  catchcmd ".import FOO BAR"
          439  +do_test shell1-3.11.2 {
          440  +  catchcmd " test.db" ".import FOO BAR"
   300    441   } {1 {Error: no such table: BAR}}
   301         -do_test shell1-2.11.3 {
          442  +do_test shell1-3.11.3 {
   302    443     # too many arguments
   303         -  catchcmd ".import FOO BAR BAD"
          444  +  catchcmd " test.db" ".import FOO BAR BAD"
   304    445   } {1 {Error: unknown command or invalid arguments:  "import". Enter ".help" for help}}
   305    446   
   306    447   # .indices ?TABLE?       Show names of all indices
   307    448   #                          If TABLE specified, only show indices for tables
   308    449   #                          matching LIKE pattern TABLE.
   309         -do_test shell1-2.12.1 {
   310         -  catchcmd ".indices"
          450  +do_test shell1-3.12.1 {
          451  +  catchcmd " test.db" ".indices"
   311    452   } {0 {}}
   312         -do_test shell1-2.12.2 {
   313         -  catchcmd ".indices FOO"
          453  +do_test shell1-3.12.2 {
          454  +  catchcmd " test.db" ".indices FOO"
   314    455   } {0 {}}
   315         -do_test shell1-2.12.3 {
          456  +do_test shell1-3.12.3 {
   316    457     # too many arguments
   317         -  catchcmd ".indices FOO BAD"
          458  +  catchcmd " test.db" ".indices FOO BAD"
   318    459   } {1 {Error: unknown command or invalid arguments:  "indices". Enter ".help" for help}}
   319    460   
   320    461   # .mode MODE ?TABLE?     Set output mode where MODE is one of:
   321    462   #                          csv      Comma-separated values
   322    463   #                          column   Left-aligned columns.  (See .width)
   323    464   #                          html     HTML <table> code
   324    465   #                          insert   SQL insert statements for TABLE
   325    466   #                          line     One value per line
   326    467   #                          list     Values delimited by .separator string
   327    468   #                          tabs     Tab-separated values
   328    469   #                          tcl      TCL list elements
   329         -do_test shell1-2.13.1 {
   330         -  catchcmd ".mode"
          470  +do_test shell1-3.13.1 {
          471  +  catchcmd " test.db" ".mode"
   331    472   } {1 {Error: unknown command or invalid arguments:  "mode". Enter ".help" for help}}
   332         -do_test shell1-2.13.2 {
   333         -  catchcmd ".mode FOO"
          473  +do_test shell1-3.13.2 {
          474  +  catchcmd " test.db" ".mode FOO"
   334    475   } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
   335         -do_test shell1-2.13.3 {
   336         -  catchcmd ".mode csv"
   337         -} {0 {}}
   338         -do_test shell1-2.13.4 {
   339         -  catchcmd ".mode column"
   340         -} {0 {}}
   341         -do_test shell1-2.13.5 {
   342         -  catchcmd ".mode html"
   343         -} {0 {}}
   344         -do_test shell1-2.13.6 {
   345         -  catchcmd ".mode insert"
   346         -} {0 {}}
   347         -do_test shell1-2.13.7 {
   348         -  catchcmd ".mode line"
   349         -} {0 {}}
   350         -do_test shell1-2.13.8 {
   351         -  catchcmd ".mode list"
   352         -} {0 {}}
   353         -do_test shell1-2.13.9 {
   354         -  catchcmd ".mode tabs"
   355         -} {0 {}}
   356         -do_test shell1-2.13.10 {
   357         -  catchcmd ".mode tcl"
   358         -} {0 {}}
   359         -do_test shell1-2.13.11 {
   360         -  # too many arguments
   361         -  catchcmd ".mode tcl BAD"
          476  +do_test shell1-3.13.3 {
          477  +  catchcmd " test.db" ".mode csv"
          478  +} {0 {}}
          479  +do_test shell1-3.13.4 {
          480  +  catchcmd " test.db" ".mode column"
          481  +} {0 {}}
          482  +do_test shell1-3.13.5 {
          483  +  catchcmd " test.db" ".mode html"
          484  +} {0 {}}
          485  +do_test shell1-3.13.6 {
          486  +  catchcmd " test.db" ".mode insert"
          487  +} {0 {}}
          488  +do_test shell1-3.13.7 {
          489  +  catchcmd " test.db" ".mode line"
          490  +} {0 {}}
          491  +do_test shell1-3.13.8 {
          492  +  catchcmd " test.db" ".mode list"
          493  +} {0 {}}
          494  +do_test shell1-3.13.9 {
          495  +  catchcmd " test.db" ".mode tabs"
          496  +} {0 {}}
          497  +do_test shell1-3.13.10 {
          498  +  catchcmd " test.db" ".mode tcl"
          499  +} {0 {}}
          500  +do_test shell1-3.13.11 {
          501  +  # too many arguments
          502  +  catchcmd " test.db" ".mode tcl BAD"
   362    503   } {1 {Error: invalid arguments:  "BAD". Enter ".help" for help}}
   363    504   
   364    505   # don't allow partial mode type matches
   365         -do_test shell1-2.13.12 {
   366         -  catchcmd ".mode l"
          506  +do_test shell1-3.13.12 {
          507  +  catchcmd " test.db" ".mode l"
   367    508   } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
   368         -do_test shell1-2.13.13 {
   369         -  catchcmd ".mode li"
          509  +do_test shell1-3.13.13 {
          510  +  catchcmd " test.db" ".mode li"
   370    511   } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
   371         -do_test shell1-2.13.14 {
   372         -  catchcmd ".mode lin"
          512  +do_test shell1-3.13.14 {
          513  +  catchcmd " test.db" ".mode lin"
   373    514   } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
   374    515   
   375    516   # .nullvalue STRING      Print STRING in place of NULL values
   376         -do_test shell1-2.14.1 {
   377         -  catchcmd ".nullvalue"
          517  +do_test shell1-3.14.1 {
          518  +  catchcmd " test.db" ".nullvalue"
   378    519   } {1 {Error: unknown command or invalid arguments:  "nullvalue". Enter ".help" for help}}
   379         -do_test shell1-2.14.2 {
   380         -  catchcmd ".nullvalue FOO"
          520  +do_test shell1-3.14.2 {
          521  +  catchcmd " test.db" ".nullvalue FOO"
   381    522   } {0 {}}
   382         -do_test shell1-2.14.3 {
          523  +do_test shell1-3.14.3 {
   383    524     # too many arguments
   384         -  catchcmd ".nullvalue FOO BAD"
          525  +  catchcmd " test.db" ".nullvalue FOO BAD"
   385    526   } {1 {Error: unknown command or invalid arguments:  "nullvalue". Enter ".help" for help}}
   386    527   
   387    528   # .output FILENAME       Send output to FILENAME
   388         -do_test shell1-2.15.1 {
   389         -  catchcmd ".output"
          529  +do_test shell1-3.15.1 {
          530  +  catchcmd " test.db" ".output"
   390    531   } {1 {Error: unknown command or invalid arguments:  "output". Enter ".help" for help}}
   391         -do_test shell1-2.15.2 {
   392         -  catchcmd ".output FOO"
          532  +do_test shell1-3.15.2 {
          533  +  catchcmd " test.db" ".output FOO"
   393    534   } {0 {}}
   394         -do_test shell1-2.15.3 {
          535  +do_test shell1-3.15.3 {
   395    536     # too many arguments
   396         -  catchcmd ".output FOO BAD"
          537  +  catchcmd " test.db" ".output FOO BAD"
   397    538   } {1 {Error: unknown command or invalid arguments:  "output". Enter ".help" for help}}
   398    539   
   399    540   # .output stdout         Send output to the screen
   400         -do_test shell1-2.16.1 {
   401         -  catchcmd ".output stdout"
          541  +do_test shell1-3.16.1 {
          542  +  catchcmd " test.db" ".output stdout"
   402    543   } {0 {}}
   403         -do_test shell1-2.16.2 {
          544  +do_test shell1-3.16.2 {
   404    545     # too many arguments
   405         -  catchcmd ".output stdout BAD"
          546  +  catchcmd " test.db" ".output stdout BAD"
   406    547   } {1 {Error: unknown command or invalid arguments:  "output". Enter ".help" for help}}
   407    548   
   408    549   # .prompt MAIN CONTINUE  Replace the standard prompts
   409         -do_test shell1-2.17.1 {
   410         -  catchcmd ".prompt"
          550  +do_test shell1-3.17.1 {
          551  +  catchcmd " test.db" ".prompt"
   411    552   } {1 {Error: unknown command or invalid arguments:  "prompt". Enter ".help" for help}}
   412         -do_test shell1-2.17.2 {
   413         -  catchcmd ".prompt FOO"
          553  +do_test shell1-3.17.2 {
          554  +  catchcmd " test.db" ".prompt FOO"
   414    555   } {0 {}}
   415         -do_test shell1-2.17.3 {
   416         -  catchcmd ".prompt FOO BAR"
          556  +do_test shell1-3.17.3 {
          557  +  catchcmd " test.db" ".prompt FOO BAR"
   417    558   } {0 {}}
   418         -do_test shell1-2.17.4 {
          559  +do_test shell1-3.17.4 {
   419    560     # too many arguments
   420         -  catchcmd ".prompt FOO BAR BAD"
          561  +  catchcmd " test.db" ".prompt FOO BAR BAD"
   421    562   } {1 {Error: unknown command or invalid arguments:  "prompt". Enter ".help" for help}}
   422    563   
   423    564   # .quit                  Exit this program
   424         -do_test shell1-2.18.1 {
   425         -  catchcmd ".quit"
          565  +do_test shell1-3.18.1 {
          566  +  catchcmd " test.db" ".quit"
   426    567   } {0 {}}
   427         -do_test shell1-2.18.2 {
          568  +do_test shell1-3.18.2 {
   428    569     # too many arguments
   429         -  catchcmd ".quit BAD"
          570  +  catchcmd " test.db" ".quit BAD"
   430    571   } {1 {Error: unknown command or invalid arguments:  "quit". Enter ".help" for help}}
   431    572   
   432    573   # .read FILENAME         Execute SQL in FILENAME
   433         -do_test shell1-2.19.1 {
   434         -  catchcmd ".read"
          574  +do_test shell1-3.19.1 {
          575  +  catchcmd " test.db" ".read"
   435    576   } {1 {Error: unknown command or invalid arguments:  "read". Enter ".help" for help}}
   436         -do_test shell1-2.19.2 {
          577  +do_test shell1-3.19.2 {
   437    578     file delete -force FOO
   438         -  catchcmd ".read FOO"
          579  +  catchcmd " test.db" ".read FOO"
   439    580   } {1 {Error: cannot open "FOO"}}
   440         -do_test shell1-2.19.3 {
          581  +do_test shell1-3.19.3 {
   441    582     # too many arguments
   442         -  catchcmd ".read FOO BAD"
          583  +  catchcmd " test.db" ".read FOO BAD"
   443    584   } {1 {Error: unknown command or invalid arguments:  "read". Enter ".help" for help}}
   444    585   
   445    586   # .restore ?DB? FILE     Restore content of DB (default "main") from FILE
   446         -do_test shell1-2.20.1 {
   447         -  catchcmd ".restore"
          587  +do_test shell1-3.20.1 {
          588  +  catchcmd " test.db" ".restore"
   448    589   } {1 {Error: unknown command or invalid arguments:  "restore". Enter ".help" for help}}
   449         -do_test shell1-2.20.2 {
   450         -  # catchcmd ".restore FOO"
          590  +do_test shell1-3.20.2 {
          591  +  # catchcmd " test.db" ".restore FOO"
   451    592     #TBD!!! this asserts currently
   452    593   } {}
   453         -do_test shell1-2.20.3 {
   454         -  catchcmd ".restore FOO BAR"
          594  +do_test shell1-3.20.3 {
          595  +  catchcmd " test.db" ".restore FOO BAR"
   455    596   } {1 {Error: unknown database FOO}}
   456         -do_test shell1-2.20.4 {
          597  +do_test shell1-3.20.4 {
   457    598     # too many arguments
   458         -  catchcmd ".restore FOO BAR BAD"
          599  +  catchcmd " test.db" ".restore FOO BAR BAD"
   459    600   } {1 {Error: unknown command or invalid arguments:  "restore". Enter ".help" for help}}
   460    601   
   461    602   # .schema ?TABLE?        Show the CREATE statements
   462    603   #                          If TABLE specified, only show tables matching
   463    604   #                          LIKE pattern TABLE.
   464         -do_test shell1-2.21.1 {
   465         -  catchcmd ".schema"
          605  +do_test shell1-3.21.1 {
          606  +  catchcmd " test.db" ".schema"
   466    607   } {0 {}}
   467         -do_test shell1-2.21.2 {
   468         -  catchcmd ".schema FOO"
          608  +do_test shell1-3.21.2 {
          609  +  catchcmd " test.db" ".schema FOO"
   469    610   } {0 {}}
   470         -do_test shell1-2.21.3 {
          611  +do_test shell1-3.21.3 {
   471    612     # too many arguments
   472         -  catchcmd ".schema FOO BAD"
          613  +  catchcmd " test.db" ".schema FOO BAD"
   473    614   } {1 {Error: unknown command or invalid arguments:  "schema". Enter ".help" for help}}
   474    615   
   475    616   # .separator STRING      Change separator used by output mode and .import
   476         -do_test shell1-2.22.1 {
   477         -  catchcmd ".separator"
          617  +do_test shell1-3.22.1 {
          618  +  catchcmd " test.db" ".separator"
   478    619   } {1 {Error: unknown command or invalid arguments:  "separator". Enter ".help" for help}}
   479         -do_test shell1-2.22.2 {
   480         -  catchcmd ".separator FOO"
          620  +do_test shell1-3.22.2 {
          621  +  catchcmd " test.db" ".separator FOO"
   481    622   } {0 {}}
   482         -do_test shell1-2.22.3 {
          623  +do_test shell1-3.22.3 {
   483    624     # too many arguments
   484         -  catchcmd ".separator FOO BAD"
          625  +  catchcmd " test.db" ".separator FOO BAD"
   485    626   } {1 {Error: unknown command or invalid arguments:  "separator". Enter ".help" for help}}
   486    627   
   487    628   # .show                  Show the current values for various settings
   488         -do_test shell1-2.23.1 {
   489         -  set res [catchcmd ".show"]
          629  +do_test shell1-3.23.1 {
          630  +  set res [catchcmd " test.db" ".show"]
   490    631     list [regexp {echo:} $res] \
   491    632          [regexp {explain:} $res] \
   492    633          [regexp {headers:} $res] \
   493    634          [regexp {mode:} $res] \
   494    635          [regexp {nullvalue:} $res] \
   495    636          [regexp {output:} $res] \
   496    637          [regexp {separator:} $res] \
   497    638          [regexp {width:} $res]
   498    639   } {1 1 1 1 1 1 1 1}
   499         -do_test shell1-2.23.2 {
          640  +do_test shell1-3.23.2 {
   500    641     # too many arguments
   501         -  catchcmd ".show BAD"
          642  +  catchcmd " test.db" ".show BAD"
   502    643   } {1 {Error: unknown command or invalid arguments:  "show". Enter ".help" for help}}
   503    644   
   504    645   # .tables ?TABLE?        List names of tables
   505    646   #                          If TABLE specified, only list tables matching
   506    647   #                          LIKE pattern TABLE.
   507         -do_test shell1-2.24.1 {
   508         -  catchcmd ".tables"
          648  +do_test shell1-3.24.1 {
          649  +  catchcmd " test.db" ".tables"
   509    650   } {0 {}}
   510         -do_test shell1-2.24.2 {
   511         -  catchcmd ".tables FOO"
          651  +do_test shell1-3.24.2 {
          652  +  catchcmd " test.db" ".tables FOO"
   512    653   } {0 {}}
   513         -do_test shell1-2.24.3 {
          654  +do_test shell1-3.24.3 {
   514    655     # too many arguments
   515         -  catchcmd ".tables FOO BAD"
          656  +  catchcmd " test.db" ".tables FOO BAD"
   516    657   } {1 {Error: unknown command or invalid arguments:  "tables". Enter ".help" for help}}
   517    658   
   518    659   # .timeout MS            Try opening locked tables for MS milliseconds
   519         -do_test shell1-2.25.1 {
   520         -  catchcmd ".timeout"
          660  +do_test shell1-3.25.1 {
          661  +  catchcmd " test.db" ".timeout"
   521    662   } {1 {Error: unknown command or invalid arguments:  "timeout". Enter ".help" for help}}
   522         -do_test shell1-2.25.2 {
   523         -  catchcmd ".timeout zzz"
          663  +do_test shell1-3.25.2 {
          664  +  catchcmd " test.db" ".timeout zzz"
   524    665     # this should be treated the same as a '0' timeout
   525    666   } {0 {}}
   526         -do_test shell1-2.25.3 {
   527         -  catchcmd ".timeout 1"
          667  +do_test shell1-3.25.3 {
          668  +  catchcmd " test.db" ".timeout 1"
   528    669   } {0 {}}
   529         -do_test shell1-2.25.4 {
          670  +do_test shell1-3.25.4 {
   530    671     # too many arguments
   531         -  catchcmd ".timeout 1 BAD"
          672  +  catchcmd " test.db" ".timeout 1 BAD"
   532    673   } {1 {Error: unknown command or invalid arguments:  "timeout". Enter ".help" for help}}
   533    674   
   534    675   # .width NUM NUM ...     Set column widths for "column" mode
   535         -do_test shell1-2.26.1 {
   536         -  catchcmd ".width"
          676  +do_test shell1-3.26.1 {
          677  +  catchcmd " test.db" ".width"
   537    678   } {1 {Error: unknown command or invalid arguments:  "width". Enter ".help" for help}}
   538         -do_test shell1-2.26.2 {
   539         -  catchcmd ".width xxx"
          679  +do_test shell1-3.26.2 {
          680  +  catchcmd " test.db" ".width xxx"
   540    681     # this should be treated the same as a '0' width for col 1
   541    682   } {0 {}}
   542         -do_test shell1-2.26.3 {
   543         -  catchcmd ".width xxx yyy"
          683  +do_test shell1-3.26.3 {
          684  +  catchcmd " test.db" ".width xxx yyy"
   544    685     # this should be treated the same as a '0' width for col 1 and 2
   545    686   } {0 {}}
   546         -do_test shell1-2.26.4 {
   547         -  catchcmd ".width 1 1"
          687  +do_test shell1-3.26.4 {
          688  +  catchcmd " test.db" ".width 1 1"
   548    689     # this should be treated the same as a '1' width for col 1 and 2
   549    690   } {0 {}}
   550    691   
   551    692   # .timer ON|OFF          Turn the CPU timer measurement on or off
   552         -do_test shell1-2.27.1 {
   553         -  catchcmd ".timer"
          693  +do_test shell1-3.27.1 {
          694  +  catchcmd " test.db" ".timer"
   554    695   } {1 {Error: unknown command or invalid arguments:  "timer". Enter ".help" for help}}
   555         -do_test shell1-2.27.2 {
   556         -  catchcmd ".timer ON"
          696  +do_test shell1-3.27.2 {
          697  +  catchcmd " test.db" ".timer ON"
   557    698   } {0 {}}
   558         -do_test shell1-2.27.3 {
   559         -  catchcmd ".timer OFF"
          699  +do_test shell1-3.27.3 {
          700  +  catchcmd " test.db" ".timer OFF"
   560    701   } {0 {}}
   561         -do_test shell1-2.27.4 {
          702  +do_test shell1-3.27.4 {
   562    703     # too many arguments
   563         -  catchcmd ".timer OFF BAD"
          704  +  catchcmd " test.db" ".timer OFF BAD"
   564    705   } {1 {Error: unknown command or invalid arguments:  "timer". Enter ".help" for help}}
   565    706   
   566    707   # 

Changes to tool/shell2.test.

    16     16   
    17     17   # Test plan:
    18     18   #
    19     19   #   shell2-1.*: Misc. test of various tickets and reported errors.
    20     20   #
    21     21   
    22     22   package require sqlite3
           23  +
           24  +set CLI "./sqlite"
    23     25   
    24     26   proc do_test {name cmd expected} {
    25     27     puts -nonewline "$name ..."
    26     28     set res [uplevel $cmd]
    27     29     if {$res eq $expected} {
    28     30       puts Ok
    29     31     } else {
................................................................................
    39     41   }
    40     42   
    41     43   proc catchsql {sql} {
    42     44     set rc [catch {uplevel [list db eval $sql]} msg]
    43     45     list $rc $msg
    44     46   }
    45     47   
    46         -proc catchcmd {options db cmd} {
           48  +proc catchcmd {db cmd} {
           49  +  global CLI
    47     50     set out [open cmds.txt w]
    48     51     puts $out $cmd
    49     52     close $out
    50         -  set rc [catch { exec ./sqlite $options $db < cmds.txt } msg]
           53  +  set line "exec $CLI $db < cmds.txt"
           54  +  set rc [catch { eval $line } msg]
    51     55     list $rc $msg
    52     56   }
    53     57   
    54     58   file delete -force test.db test.db.journal
    55     59   sqlite3 db test.db
    56     60   
    57     61   
    58     62   #----------------------------------------------------------------------------
    59     63   #   shell2-1.*: Misc. test of various tickets and reported errors.
    60     64   #
    61     65   
    62     66   # Batch mode not creating databases.  
    63         -# Reported on mailing list by Ken Zalewski <kennyz@nycap.rr.com>.
           67  +# Reported on mailing list by Ken Zalewski.
    64     68   # Ticket [aeff892c57].
    65     69   do_test shell2-1.1.1 {
    66     70     file delete -force foo.db
    67         -  set rc [ catchcmd "-batch" "foo.db" "CREATE TABLE t1(a);" ]
           71  +  set rc [ catchcmd "-batch foo.db" "CREATE TABLE t1(a);" ]
    68     72     set fexist [file exist foo.db]
    69     73     list $rc $fexist
    70     74   } {{0 {}} 1}
           75  +
           76  +# Shell silently ignores extra parameters.
           77  +# Ticket [f5cb008a65].
           78  +do_test shell2-1.2.1 {
           79  +  set rc [catch { eval exec $CLI \":memory:\" \"select 3\" \"select 4\" } msg]
           80  +  list $rc \
           81  +       [regexp {Error: too many options: "select 4"} $msg]
           82  +} {1 1}
           83  +
           84  +
    71     85