]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Sync w/Trunk, finish doc/sh_tweak_changes.md
authorlarrybr <larrybr@noemail.net>
Wed, 9 Mar 2022 22:16:38 +0000 (22:16 +0000)
committerlarrybr <larrybr@noemail.net>
Wed, 9 Mar 2022 22:16:38 +0000 (22:16 +0000)
FossilOrigin-Name: 5a1797c2250665d013e0a1818f90c52db1b6f67b2daff82c46c06c9d058080e7

1  2 
doc/sh_tweak_changes.md
manifest
manifest.uuid
src/shell.c.in
test/shell5.test
test/shell9.test

index 4cae7446e2a3f825b7f1c387ff4ed4cbd5aa6f92,0000000000000000000000000000000000000000..4b5c8b1f6a217e86f5a7613bdf5f3955849e5162
mode 100644,000000..100644
--- /dev/null
@@@ -1,124 -1,0 +1,128 @@@
- # Feature changes on shell-tweaks branch.
++# <u>Feature changes on shell-tweaks branch.</u>
 +
 +This section summarizes the changes; motivation is addressed further below.
 +
 +## (internal) Input stream management improvements:
 +* line number tracking centralized, done at arbitrary nesting
 +* source tracking centralized, done at arbitrary nesting
 +* input from either an open FILE or string content (for .x feature)
 +* stream switch save/restore simplified in several places
 +
 +
 +## Extension features made optional at build-time or runtime, for backwards compatibility. (Described further per-feature.)
 +
 +## (internal) Query output display mode stack implemented and used. (Associated ShellState reorg supports this, and groups members more by purpose.)
 +
 +## (internal) Expand temp.sqlite_parameters usage to include "scripts", with an extra column, "uses", limiting role of variables to either binding or execution.
 +
 +## (internal) Refactoring and interface adjustments to allow resuse by new code of previously buried operations or utility routines.
 +
 +## Add --schema SCHEMA option to .dump
 +
 +## Many changes and additions to .parameter subcommands:
 +
 +### clear ?NAME? to allow selective zapping. (Was everything before.)
 +
- ### edit ?OPT? NAME to allow editing an existing or new entry. The OPT, if provided, may be -t or -e to select whether the resulting value is stored as text or evaluated as a SQL expression. A hidden option, --editor=<something>, may be used in place of having set environment variable DISPLAY before starting shell. This option is mentioned just when needed in an interactive session.
++### edit ?OPT? NAME to allow editing an existing or new entry. The OPT, if provided, may be -t or -e to select whether the resulting value is stored as text or evaluated as a SQL expression. A hidden option, --editor=\<something\>, may be used in place of having set environment variable DISPLAY before starting shell. This option is mentioned just when needed in an interactive session.
 +
 +### list/ls output options, prettified with optional glob patterns.
 +
 +### load ?FILE? ?NAMES? to allow saved parameters to be loaded. With no arguments, a defaulted file in user's HOME directory is the source, and all of its parameters are loaded. With a FILE argument, named file is the source. With more arguments, selective loading from the file is done.
 +
 +### save ?FILE? ?NAMES? is parallel to load except for direction of data flow and intolerance of FILE being read-only.
 +
 +### set ?TOPT? NAME VALUE accepts an optional type option to specify storage of the given value as a particular type, bypassing the old, "evaluate as SQL expression" behavior (which can be problematic without two levels of quoting.) Without the type option, the old behavior occurs. Also, if multiple arguments are found where VALUE would be, they are space-joined to form the stored value. (This is convenient for script use.)
 +
 +### unset ?NAMES? is much like "clear ?NAMES?", except that with no names it is a no-op rather than an error as with prior shell versions.
 +
 +## .shxopts command added to display or modify extension options.
 +
 +## .x NAMES command added to execute named parameters as if their content was fed to the input stream.
 +
 +## Certain dot-commands become "undocumented".
 +
 +This means that, in addition to not appearing in the website docs, they do not appear in the normal .help output. Help for them is available by entering ".help -all -all", and this is mentioned in the output of ".help -all" and ".help help".
 +
 +Undocumented dot commands are: .check, .selftest-*, .seeargs, .testcase, and .testctrl .
 +
 +## .seeargs command added to show its arguments bounded by '|', for those who are unsure of the shell's quoting and expansion rules.
 +
 +## For .open command, --hexdb option without a FILE given can read in a hex DB from the current input stream, including from string sources.
 +
 +## (internal) Compile option, BOOLNAMES_ARE_BOOLEAN, adds "false" and "true" to the recognized binary switch values.
 +
 +## (internal) Utility function, db_text(), added. It resembles db_int().
 +
 +## (internal) Preparation made for variable expansion within double-quoted command arguments. (This is not a visible or completed feature, so now "internal".)
 +
 +## Dot-command parsing is optionally extended to permit arguments to span more than one line, or more arguments to be added in subsequent lines. This is not the default behavior because it breaks backward compatibility (for ill-formed input with mis-balanced quotes.) It is enabled with either an invocation command-line option or the dot-commad, ".shxopts +parsing". With extended parsing, unclosed arguments may contain literal newlines, and lines may be be spliced if backslash is the final character (other than newline) at the end of an input line.
 +
- ## (internal) Input line processing (process_input()) rewritten to support collection and dispatch of multi-line input in a more regular manner. This will be easily adapted to incorporate TCL scripting when (or if) that is added.
++## (internal) Input line processing (process_input()) rewritten to support collection and dispatch of multi-line input in a more regular manner.
 +
 +## (internal) process_input() is over-commented to aid initial write and review if desired. Its comment volume is slated for post-merge reduction.
 +
- ## (semi-internal) An undocumented command-line option, -quiet, added to suppress start-up banner (which contains a version string) and prompts when input is "interactive". This facilitates testing of the ".parameter edit" feature.
++## (semi-internal) An undocumented command-line option, -quiet, added to suppress start-up banner (which contains a version string) and prompts when input is "interactive".
 +
 +## (internal) Tests added for above new/changed features.
 +
 +## (internal) mkshellc.tcl usefully handles simple typedefs with comments.
 +
- # Motivation or justification for above shell-tweaks branch changes.
++# <u>Motivation or justification for above shell-tweaks branch changes.</u>
 +
 +The changes marked "(internal)" are generally made to either simplify the code, or to manage its complexity in a more readily understood way. It can mostly be categorized as "showing a little love" for the affected code where not strictly necessary for feature implementation.
 +
 +## Input stream management improvements
 +
 +This set of changes makes it easier to manage input streams, as can be seen by the impact on client code where that happens. Additionally, better error reporting is made possible from within nested sources.
 +
 +## Extension features made optional
 +
 +The build-time feature trimming option is for resource-constrained environments. It also serves the purpose of showing where code can be chopped out or how it can be adapted if the feature is vetoed. It may also show the feature's impact on code volume.
 +
 +Runtime feature enable/disable is for features that impact backward compatibility. For example, with present releases, if the last argument for a dot command has an opening quote but no closing quote, it is considered closed by the end-of-line. With the command parsing extension enabled, such a construct begins an argument spanning more than one line. To avoid breaking old script input to the CLI, which may have such ill-formed arguments, the extension is disabled by default.
 +
 +## Query output display mode stack
 +
 +This is mainly a clean-up of existing functionality. It also anticipates future mode save/restore that may be exposed to users.
 +
 +## Expand temp.sqlite_parameters usage to include "scripts"
 +
 +This internal change reflects an implementation choice in support of scripting. It could have been done with a separate table, but this simplifies the code, UI, and documentation (to come.)
 +
 +## Refactoring and interface adjustments to allow resuse.
 +
 +Clean-up and maintenance burden reduction mainly motivates this.
 +
 +## Add --schema SCHEMA option to .dump
 +
 +Simplifies scenarios where a user attaches a DB, or creates an attached DB, for the purpose of transfering data to it from a main DB and then saving it out in .dump format. Similar convenience is made available for the TEMP DB.
 +
 +## Changes and additions to .parameter subcommands
 +
 +The .parameter command becomes the focal point for managing all kinds of user-alterable parameters and variables. It is easy to remember: If some parameter(s) will be created, modified, reviewed, saved, loaded, or removed, .parameter is how it is done.
 +
 +### clear or unset ?NAMES? are enhanced to conveniently remove just selected parameters, (rather than all of them as before), for pre-save cleanup, list de-clutter, or testing effect of unbound query parameters.
 +
- ### edit ?OPT? NAME is added to aid convenient interactive creation or modification of parameter values, particularly ones that may have multiple lines or tax a user's perception when only a line-editor is available. The feature is only enabled for interactive sessions, as it makes little sense to begin an edit session in batch mode. Its hidden option, --editor=<something>, is for cases where a user has not set DISPLAY before starting the CLI, or needs to change it. It does not appear in help, but is mentioned when edit is invoked without DISPLAY being set.
++### edit ?OPT? NAME is added to aid convenient interactive creation or modification of parameter values, particularly ones that may have multiple lines or tax a user's perception when only a line-editor is available. The feature is only enabled for interactive sessions, as it makes little sense to begin an edit session in batch mode. Its hidden option, --editor=\<something\>, is for cases where a user has not set DISPLAY before starting the CLI, or needs to change it. It does not appear in help, but is mentioned when edit is invoked without DISPLAY being set.
 +
 +### load/save ?FILE? ?NAMES? is a persistence facility mainly for edited queries, DDL or DML that a user may wish to reuse across sessions. Or it may prove useful for commonly repeated sequences of dot commands. Or both.
 +
 +### list/ls output options make it easier to see what is in the parameters table by using the short, "ls" form, which lists only names, or by specifying glob patterns to restrict output.
 +
 +### set ?TOPT? NAME VALUE gained the option, TOPT, to force the value's type or to bypass the effective eval trial for text. Taking the VALUE to be the space-joined remaining arguments simplifies quoting in many cases.
 +
 +## Added .shxopts command to allow certain optional features, which potentially impair backward compatibility, to be enabled or disabled at runtime.
 +
 +## The new dot command, .x NAMES, is added to allow convenient execution of pre-written or edited SQL and command sequences.
 +
 +## Certain dot-commands become "undocumented" to reduce clutter seen by those who use the CLI to use SQLite rather than to test it.
 +
 +## Compile option, BOOLNAMES_ARE_BOOLEAN is a place-holder for until addition of "false" and "true" to the binary switch name set is rejected or accepted. The case for adding them is that they are a natural choice as boolean values and having "true" taken as "false" (as happens today) can be surprising.
 +
- ## Extended dot-command parsing, (where arguments and/or dot commands may span line-ends), has several uses. One is for allowing ".param set <name> <value>" to specify a multi-line value, useful mainly for script creation. (Otherwise, multi-line script, which may contain complex SQL in need of line-structure, can only be created by using ".parameter edit <name>".) Another is for .print commands, so that literal multi-line output may be more naturally specified.
++## Extended dot-command parsing, (where arguments and/or dot commands may span line-ends), has several uses. One is for allowing ".param set \<name\> \<value\>" to specify a multi-line value, useful mainly for script creation. (Otherwise, multi-line script, which may contain complex SQL in need of line-structure, can only be created by using ".parameter edit \<name\>".) Another is for .print commands, so that literal multi-line output may be more naturally specified.
 +
++## The process_input() rewrite was needed to support extended dot-command parsing. The difficulty of gaining that support without a rewrite, together with anticipation of later adding a TCL input feature, (which would present similar issues), easily made the rewrite appear advantageous. The code was hard to follow before, but can now be easily adapted to incorporate TCL scripting when (or if) that is added.
 +
++## The added command-line option, -quiet, facilitates testing of the ".parameter edit" feature.
++
++## The mkshellc.tcl change to handle more typedef repetition than before merely reduces the fragility of the feature. It was motivated by added use of a sometimes-redundant typedef which exposed the older fragility.
diff --cc manifest
index 1e40f3896d3c2419f7fc35480d0416e9f1d38d93,ea1836c448981efd73a556ff5086e78a1f330619..f28e6680f1c8906b502db5cd5dc613a6659f55aa
+++ b/manifest
@@@ -1,5 -1,5 +1,5 @@@
- C Add\sa\s.md\ssummarizing\sCLI\schanges\son\sthis\sbranch\sand\stheir\smotivation\sor\spurpose.
- D 2022-03-08T03:10:58.490
 -C Further\srefinements\sto\sthe\ssqlite_offset()\sfix\sfrom\s[6029514b08b88e3f].
 -D 2022-03-09T18:29:19.102
++C Sync\sw/Trunk,\sfinish\sdoc/sh_tweak_changes.md
++D 2022-03-09T22:16:38.326
  F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
  F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
  F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@@ -41,7 -41,6 +41,7 @@@ F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019
  F doc/json-enhancements.md e356fc834781f1f1aa22ee300027a270b2c960122468499bf347bb123ce1ea4f
  F doc/lemon.html efc0cd2345d66905505d98f862e1c571512def0ceb5b016cb658fd4918eb76a3
  F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710
- F doc/sh_tweak_changes.md 274b5286a0cae9e7152e805fd6e15d1c3a60b47b520c7d33d121e36dbc2d658d
++F doc/sh_tweak_changes.md 5a9fbf65817433ddc4493cd328266a8918b70cd90bde7162c92eea59c61093d8
  F doc/trusted-schema.md 33625008620e879c7bcfbbfa079587612c434fa094d338b08242288d358c3e8a
  F doc/vdbesort-memory.md 4da2639c14cd24a31e0af694b1a8dd37eaf277aff3867e9a8cc14046bc49df56
  F doc/vfs-shm.txt e101f27ea02a8387ce46a05be2b1a902a021d37a
@@@ -553,12 -552,12 +553,12 @@@ F src/printf.c 05d8dfd2018bc4fc3ddb8b37
  F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c
  F src/resolve.c ea935b87d6fb36c78b70cdc7b28561dc8f33f2ef37048389549c7b5ef9b0ba5e
  F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
- F src/select.c 3baa9dd8cf240654773c7974e2bcce398ac9dd24419c36684156963defe43b35
- F src/shell.c.in 5a8a5350b7284f185aed21c140e6c81a33b54873f89a3568600cf6a37dd4acac
- F src/sqlite.h.in e30cedf008d9c51511f4027a3739b727a588da553424748b48d2393f85dbde41
+ F src/select.c 4890a3cfee0bc60ff231c3a44db37968859ab0be156983dbcc0c096109832cdd
 -F src/shell.c.in 69d1e59da4881f096ab47fbd3e6d99794f3e4a43f41fd9e4d2e845c9b8d20fd5
++F src/shell.c.in 68eddd95fa2a3545499e3f9c59cf28aff483589884c42fa7de10931afce7aa42
+ F src/sqlite.h.in e82ac380b307659d0892f502b742f825504e78729f4edaadce946003b9c00816
  F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
  F src/sqlite3ext.h a95cb9ed106e3d39e2118e4dcc15a14faec3fa50d0093425083d340d9dfd96e6
- F src/sqliteInt.h f8814239fb1f95056555e2d7fa475750e64681cac4221fb03610d1fde0b79d53
+ F src/sqliteInt.h a98a9cfc7e717b98f30e72545695f1ad92354fdf16df8510e80f48cf98c4adbe
  F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657
  F src/status.c 4b8bc2a6905163a38b739854a35b826c737333fab5b1f8e03fa7eb9a4799c4c1
  F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
@@@ -1391,13 -1390,12 +1391,13 @@@ F test/shared_err.test 32634e404a3317ee
  F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304
  F test/shell1.test b224e0793c5f48aa3749e65d8c64b93a30731bd206f2e41e6c5f1bee1bdb16c6
  F test/shell2.test 89e4b2db062d52baed75022227b462d085cff495809de1699652779d8e0257d6
 -F test/shell3.test a50628ab1d78d90889d9d3f32fb2c084ee15674771e96afe954aaa0accd1de3c
 -F test/shell4.test 8f6c0fce4abed19a8a7f7262517149812a04caa905d01bdc8f5e92573504b759
 -F test/shell5.test 0a9920d81fae28c45cd5dbd1deb809487a23c5f4b422a49f9d31c85f926d4a9c
 +F test/shell3.test 4ddea2bd182e7e03249911b23ae249e7cb8a91cdc86e695198725affabe8ecd3
 +F test/shell4.test 867e0675d7b096d6b93de534541e07c7f5ffafa3e6612695ecf55180802e1115
- F test/shell5.test 2b521446f55146c9aafccd0946bdb44ae288b0d25bd48f722e041974fdeeb04a
++F test/shell5.test 8f4ac4f22852cfe50259a99c31e9e0c4200ab7e901caf73777c9abca6b601814
  F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3
  F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f
  F test/shell8.test 388471d16e4de767333107e30653983f186232c0e863f4490bb230419e830aae
- F test/shell9.test 03e28206c016b27b3c79f43c3b09c843468dd8961f980e60d37117ff1ce32908
++F test/shell9.test b9a361ea2d33f4950bcedf91fe71201356c663415e24fa049feeb1f86cc25fcb
  F test/shmlock.test 3dbf017d34ab0c60abe6a44e447d3552154bd0c87b41eaf5ceacd408dd13fda5
  F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
  F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5
@@@ -1877,10 -1875,10 +1877,10 @@@ F tool/mkctimec.tcl 3147e9dfc4ad774e94f
  F tool/mkkeywordhash.c 35bfc41adacc4aa6ef6fca7fd0c63e0ec0534b78daf4d0cfdebe398216bbffc3
  F tool/mkmsvcmin.tcl 6ecab9fe22c2c8de4d82d4c46797bda3d2deac8e763885f5a38d0c44a895ab33
  F tool/mkopcodec.tcl 33d20791e191df43209b77d37f0ff0904620b28465cca6990cf8d60da61a07ef
- F tool/mkopcodeh.tcl 130b88697da6ec5b89b41844d955d08fb62c2552e889dec8c7bcecb28d8f50bd
+ F tool/mkopcodeh.tcl 5dab48c49a25452257494e9601702ab63adaba6bd54a9b382615fa52661c8f8c
  F tool/mkopts.tcl 680f785fdb09729fd9ac50632413da4eadbdf9071535e3f26d03795828ab07fa
- F tool/mkpragmatab.tcl de206c64b6e9ac8cd5e3cbd0ffe456f07d5710605ef8385d677e60ce3335ea12
+ F tool/mkpragmatab.tcl bd07bd59d45d0f3448e123d6937e9811195f9908a51e09d774609883055bfd3d
 -F tool/mkshellc.tcl df5d249617f9cc94d5c48eb0401673eb3f31f383ecbc54e8a13ca3dd97e89450
 +F tool/mkshellc.tcl 5a9e27449694b179d2facde3fa10ff5a2d689be25822526addc20a1f1d9a12ec
  F tool/mksourceid.c 36aa8020014aed0836fd13c51d6dc9219b0df1761d6b5f58ff5b616211b079b9
  F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
  F tool/mksqlite3c-noext.tcl 4f7cfef5152b0c91920355cbfc1d608a4ad242cb819f1aea07f6d0274f584a7f
@@@ -1946,8 -1944,8 +1946,8 @@@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a9
  F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
  F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
  F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
- P 8c9a5fb26ba045edef1269c5f5e8c8d87fa890b88ddb1121be72514a389a845d
- R 71c47adc11a443569caff2f1dbf51e27
 -P 642a0b4752743216271e4f855a465515ef7f6a985f280251e18d67e3d5fb694b
 -R e003996df7c18cb8469e22c2bd0a359b
 -U drh
 -Z b55793a1f68bedfa10993b4fd3b3fa4f
++P 5ddccc2f2885ae4068e492053dbb4e7215ce7dd052f782bffa0076b4585d175f 6f838305e2c848a43b210bd1b7b962fb9e3c41de34de778675e6578fcd99f397
++R d80dca76fe43cf772691a942a2518ea1
 +U larrybr
- Z aed9f03a1808985672f516d96cfa6082
++Z 6f5df54da847b7514dd0b48c6ee05b25
  # Remove this line to create a well-formed Fossil manifest.
diff --cc manifest.uuid
index 0e4106711c7a1db7c3d98d21359ee263b602158c,0643f7a01ba55caf313c9b5fa983f62b1d06ed7f..3a220123cefeb9b6d7fe5a909277593189efb42e
@@@ -1,1 -1,1 +1,1 @@@
- 5ddccc2f2885ae4068e492053dbb4e7215ce7dd052f782bffa0076b4585d175f
 -6f838305e2c848a43b210bd1b7b962fb9e3c41de34de778675e6578fcd99f397
++5a1797c2250665d013e0a1818f90c52db1b6f67b2daff82c46c06c9d058080e7
diff --cc src/shell.c.in
Simple merge
index 2237e685d5107a3ef54bb29889f8f451f8ed79c1,d63a0a20d3edd86086b4dc5eebd450757fa1532c..0a8e064c553ff1082337f74f486ac9cd00b3966a
@@@ -476,6 -476,20 +476,20 @@@ CREATE TABLE t8(a, b, c)
    db eval { SELECT * FROM t8 }
  } {1 2 3}
  
 -SELECT * FROM temp.t8
+ do_test shell5-4.4 {
+   forcedelete shell5.csv
+   set fd [open shell5.csv w]
+   puts $fd "1,2,3"
+   close $fd
+   catchcmd test.db [string trim {
+ .mode csv
+ CREATE TEMP TABLE t8(a, b, c);
+ .import shell5.csv t8
+ .nullvalue #
++SELECT * FROM temp.t8;
+   }]
+ } {0 1,2,3}
  #----------------------------------------------------------------------------
  # Tests for the shell automatic column rename.
  #
index 6113ce748a9691973284ef5e4ea4564305fcacc4,0000000000000000000000000000000000000000..64cc3009fa9410de2fc6da624854d1b3582b018b
mode 100644,000000..100644
--- /dev/null
@@@ -1,260 -1,0 +1,256 @@@
-   } {0 {.pa set @name Fido
- .pa edit -t dog
- .x dog
- Fido
-   }}
 +# 2022 Feb 5
 +#
 +# The author disclaims copyright to this source code.  In place of
 +# a legal notice, here is a blessing:
 +#
 +#    May you do good and not evil.
 +#    May you find forgiveness for yourself and forgive others.
 +#    May you share freely, never taking more than you give.
 +#
 +#***********************************************************************
 +#
 +# The focus of this file is testing the CLI shell tool enhanced parsing,
 +# new .parameter subcommands and uses, and the new .x meta-command.
 +#
 +#
 +
 +# Test plan:
 +#
 +#   shell9-1.*: command line parsing and acting accordingly
 +#   shell9-2.*: Basic "dot" command, cross-line token parsing
 +#   shell9-3.*: .parameter set options and types
 +#   shell9-4.*: .parameter save/load operation
 +#   shell9-5.*: Ensure "dot" commands and SQL intermix ok.
 +#   shell9-6.*: .x command operation and refusal
 +#
 +set testdir [file dirname $argv0]
 +source $testdir/tester.tcl
 +set CLI [test_find_cli]
 +db close
 +forcedelete test.db test.db-journal test.db-wal
 +forcedelete x.db xn.db
 +
 +sqlite3 db test.db
 +
 +#----------------------------------------------------------------------------
 +# Test cases shell9-1.*: command line parsing and acting accordingly
 +
 +do_test shell9-1.1 {
 +  set res [catchcmd ":memory: -cmd .quit" ""]
 +} {0 {}}
 +
 +do_test shell9-1.2 {
 +  set res [catchcmd ":memory: -shxopts 1 -cmd .shxopts -cmd .quit" ""]
 +} {0 {     name    value  "-shxopts set"
 +   --------  -----  ---------------
 +    parsing    1    "-shxopts 0x01"
 +   all_opts    0    "-shxopts 0x07"}}
 +
 +do_test shell9-1.3 {
 +  set res [catchcmd ":memory: -cmd .shxopts -cmd .quit" ""]
 +} {0 {     name    value  "-shxopts set"
 +   --------  -----  ---------------
 +    parsing    0    "-shxopts 0x01"
 +   all_opts    0    "-shxopts 0x07"}}
 +
 +#----------------------------------------------------------------------------
 +# Test cases shell9-2.*: Basic "dot" command, cross-line token parsing
 +
 +set cmds ".print 'l1\nl2'\n.print 'a\\\nb'"
 +do_test shell9-2.1 {
 +  set res [catchcmd ":memory: -shxopts 1" $cmds]
 +} {0 {l1
 +l2
 +ab}}
 +
 +set cmds " .print \"l1\nl2\"\n .print \"a\\\nb\" \n# c\n  ## c"
 +do_test shell9-2.2 {
 +  set res [catchcmd ":memory: -shxopts 1" $cmds]
 +} {0 {l1
 +l2
 +ab}}
 +
 +set cmds ".echo on\n.seeargs 'a'\\\n'b'\n#!"
 +do_test shell9-2.3 {
 +  set res [catchcmd ":memory: -shxopts 1" $cmds]
 +} {0 {.seeargs 'a''b'
 +a|b|}}
 +
 +set cmds ".echo on\n.seeargs a\\\nb\n#!"
 +do_test shell9-2.4 {
 +  set res [catchcmd ":memory: -shxopts 1" $cmds]
 +} {0 {.seeargs ab
 +ab|}}
 +
 +set cmds ".echo 1\n.print \"\\\"\nq\\\"\""
 +do_test shell9-2.5 {
 +  set res [catchcmd ":memory: -shxopts 1" $cmds]
 +} {0 {.print "\"
 +q\""
 +"
 +q"}}
 +
 +#----------------------------------------------------------------------------
 +# Test cases shell9-3.*: .parameter set options and types
 +
 +set cmds {
 +.pa set -b b x'a5a5'
 +.pa set -i ii 33-11
 +.pa set -i ir 3.3-1.1
 +.pa set -n ni 3-1
 +.pa set -n nr 3.3-1.1
 +.pa set -r ri 1
 +.pa set -r rr 1.2
 +.pa set -t t 123
 +.mode list
 +select typeof(value) from temp.sqlite_parameters order by key;
 +}
 +do_test shell9-3.1 {
 +  set res [catchcmd ":memory:" $cmds]
 +} {0 {blob
 +integer
 +integer
 +integer
 +real
 +real
 +real
 +text}}
 +
 +set cmds {
 +.pa set expr 1 + 2 * 3
 +.pa set text "'1 + 2*3'"
 +.pa set -t ttext 1 + 2*3
 +.pa list
 +}
 +do_test shell9-3.2 {
 +  set res [catchcmd ":memory:" $cmds]
 +} {0 {Scripts
 +name  value
 +expr  7
 +text  1 + 2*3
 +ttext 1 + 2*3}}
 +
 +set cmds {
 +.pa set a "'a'"
 +.pa set b "'b'"
 +.pa set c "'c'"
 +.pa unset
 +.pa list
 +.pa clear a
 +.pa list
 +.pa unset b
 +.pa list
 +.pa clear
 +.pa list
 +.pa set d "'e'"
 +.pa set e "'e'"
 +.pa unset d e
 +.pa list
 +}
 +do_test shell9-3.3 {
 +  set res [catchcmd ":memory:" $cmds]
 +} {0 {Scripts
 +name value
 +a    a
 +b    b
 +c    c
 +Scripts
 +name value
 +b    b
 +c    c
 +Scripts
 +name value
 +c    c}}
 +
 +if {$::tcl_platform(platform)=="unix"} {
 +  proc set_ed {sayWhat} {
 +    global env
 +    set env(VISUAL) "echo SELECT $sayWhat ';' >"
 +    return 1
 +  }
 +} elseif {$::tcl_platform(platform)=="windows"} {
 +  proc set_ed {sayWhat} {
 +    global env
 +    set env(VISUAL) "echo SELECT $sayWhat ; >"
 +    return 1
 +  }
 +} else { return 0 }
 +
 +if {[set_ed @name]} {
 +  set cmds {
 +.pa set @name Fido
 +.pa edit -t dog
 +.x dog
 +  }
 +  do_test shell9-3.4 {
 +    set res [catchcmd ":memory: -quiet 1 -shxopts 1 -interactive" $cmds]
++  } {0 Fido}
 +}
 +
 +#----------------------------------------------------------------------------
 +# Test cases shell9-4.*: .parameter save/load operation
 +
 +set cmds {
 +  .pa set -t x '.print Ex'
 +  .pa set -i $n 7
 +  .pa save xn.db
 +  .pa save x.db x
 +  .pa clear
 +  .pa load xn.db
 +  .pa list
 +  .pa clear
 +  .pa load x.db
 +  .pa list
 +  .pa clear
 +  .pa load xn.db $n
 +  .pa list
 +}
 +do_test shell9-4.1 {
 +  set res [catchcmd ":memory: -shxopts 1" $cmds]
 +} {0 {Binding Values:
 +name value
 +$n   7
 +Scripts
 +name value
 +x    .print Ex
 +Scripts
 +name value
 +x    .print Ex
 +Binding Values:
 +name value
 +$n   7}}
 +
 +forcedelete x.db xn.db
 +
 +#----------------------------------------------------------------------------
 +# Test cases shell9-5.*: Ensure "dot" commands and SQL intermix ok.
 +
 +set cmds {
 + .pa set -t mixed "
 + .print Hi.
 + select 'Hi.';
 + .print 'Good\
 + Bye.'
 + select 'Good'||
 + ' Bye.';
 + "
 + .x mixed
 +}
 +do_test shell9-5.1 {
 +  set res [catchcmd ":memory: -shxopts 1" $cmds]
 +} {0 {Hi.
 +Hi.
 +Good Bye.
 +Good Bye.}}
 +
 +#----------------------------------------------------------------------------
 +# Test cases shell9-6.*: .x command operation and refusal
 +set cmds {
 + .pa set -t $v '.print Ok'
 + .x $v
 +}
 +do_test shell9-6.1 {
 +  set res [catchcmd ":memory: -bail -shxopts 1" $cmds]
 +} {1 {Skipping badly named $v. Run ".help x"}}
 +
 +finish_test