From: drh <> Date: Mon, 13 Apr 2026 12:22:16 +0000 (+0000) Subject: ".prompt" command improvements in the CLI: Guard against mistakenly saying X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=f02d100e086d8f42714afa5a6830b5fc00d9fea1;p=thirdparty%2Fsqlite.git ".prompt" command improvements in the CLI: Guard against mistakenly saying ".prompt show" without the "--" before "show". Add the --hard-reset option to .prompt to make it more easily testable. FossilOrigin-Name: 495e4851d4296b49a37b963edd8410314de1510b2ae0b9dbe9dc0307c466c3b5 --- diff --git a/manifest b/manifest index 83e864245e..db906a9741 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\sprompt_filename()\sfunction\sin\sthe\sCLI\sso\sthat\sit\sfinds\nthe\sdatabase\sfilename\seven\sif\sthe\sconnection\sis\snot\syet\sfully\sopen. -D 2026-04-13T11:34:15.710 +C ".prompt"\scommand\simprovements\sin\sthe\sCLI:\s\sGuard\sagainst\smistakenly\ssaying\n".prompt\sshow"\swithout\sthe\s"--"\sbefore\s"show".\s\sAdd\sthe\s--hard-reset\soption\nto\s.prompt\sto\smake\sit\smore\seasily\stestable. +D 2026-04-13T12:22:16.855 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -735,7 +735,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 928ff887f2a7c64275182060d94d06fdddbe32226c569781cf7e7edc6f58d7fd F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c ffe199f025a0dd74670d2a77232bdea364a4d7b36f32c64a6572d39ba6a11576 -F src/shell.c.in 34f1f4a7f86df2309bad20160c345ca8ded319971eb8e1d8e3d439770e64c140 +F src/shell.c.in ae5a629eb8249ab5d5b61271a05e2c55b1b060794f44c5d41482dca3fb134a0c F src/sqlite.h.in 39d2e09114d2bdb7afd998f4a469c8f8cd065f8093835a7d0422f260fc78fb4f F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479 F src/sqlite3ext.h 9788c301f95370fa30e808861f1d2e6f022a816ddbe2a4f67486784c1b31db2e @@ -1619,7 +1619,7 @@ F test/sharedA.test 64bdd21216dda2c6a3bd3475348ccdc108160f34682c97f2f51c19fc0e21 F test/sharedB.test 1a84863d7a2204e0d42f2e1606577c5e92e4473fa37ea0f5bdf829e4bf8ee707 F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 -F test/shell-prompt.sql b91e31fd768a88a1b978c3d3527e408bbee605075aacabada785935c43ceacb7 +F test/shell-prompt.sql 5c18599f2b7566172007005206471aefb7e0be593e8f52d37b9ab03a12aa84a6 F test/shell1.test c84eff209f93ad17ccdf7e1634969fc8231684254edeb21d9b13d67c3179cdb5 F test/shell2.test dc541d2681503e55466a24d35a4cbf8ca5b90b8fcdef37fc4db07373a67d31d3 F test/shell3.test 91efdd545097a61a1f72cf79c9ad5b49da080f3f10282eaf4c3c272cd1012db2 @@ -2198,8 +2198,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c -P 414ae4dd65182ce571a6abb1a1a2ba2c169b204156f4f8923c42f64805a3ef9f -R cf324d5615b6d300c87a4273e5c0525e +P efb3e808a0281014512a812920d526a4909467e925ea000956606318bb6f2e65 +R 035153f7005ed7a44d470f0958cdf837 U drh -Z 7119036f9ab631d62dd86cf043f46eef +Z 8362c43c0870219aedf4cc04f1e11cb5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c0cb7e6200..723b3da5ca 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -efb3e808a0281014512a812920d526a4909467e925ea000956606318bb6f2e65 +495e4851d4296b49a37b963edd8410314de1510b2ae0b9dbe9dc0307c466c3b5 diff --git a/src/shell.c.in b/src/shell.c.in index d2e6034622..17bd59be7e 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4065,6 +4065,7 @@ static const char *(azHelp[]) = { " --timeout S Halt after running for S seconds", #endif ".prompt MAIN CONTINUE Replace the standard prompts", + " --hard-reset Unset SQLITE_PS1/2 and then --reset", " --reset Revert to default prompts", " --show Show the current prompt strings", " -- No more options. Subsequent args are prompts", @@ -10679,6 +10680,11 @@ static int do_meta_command(const char *zLine, ShellState *p){ const char *z = azArg[i]; if( z[0]=='-' && !noOpt ){ if( z[1]=='-' ) z++; + if( strcmp(z,"-hard-reset")==0 ){ + unsetenv("SQLITE_PS1"); + unsetenv("SQLITE_PS2"); + z += 5; + } if( strcmp(z,"-reset")==0 ){ free(p->azPrompt[0]); free(p->azPrompt[1]); @@ -10700,6 +10706,8 @@ static int do_meta_command(const char *zLine, ShellState *p){ dotCmdError(p, i, "extra argument", 0); rc = 1; goto meta_command_exit; + }else if( !p->dot.abQuot[i] && sqlite3_strglob("*[^a-z]*",z)!=0 ){ + dotCmdError(p, i, "use quotes around the prompt string", 0); }else{ free(p->azPrompt[cnt]); p->azPrompt[cnt] = strdup(z); diff --git a/test/shell-prompt.sql b/test/shell-prompt.sql index 6ec9cbe36e..f98874f4d8 100644 --- a/test/shell-prompt.sql +++ b/test/shell-prompt.sql @@ -19,6 +19,7 @@ .testcase setup .open -new test.db .mode list -quote off -escape ascii +.prompt --hard-reset .check '' .testcase 100 @@ -51,6 +52,40 @@ Main prompt: 'SQLite /f> ' Continuation: '/B.../H> ' END +.testcase 120 --error-prefix ERROR: +.prompt show +.check < ' +END + +.testcase 130 +.prompt --reset +.help prompt +.check <