]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Change the prompt escape design yet again, to use / as the escape character,
authordrh <>
Sat, 11 Apr 2026 23:58:15 +0000 (23:58 +0000)
committerdrh <>
Sat, 11 Apr 2026 23:58:15 +0000 (23:58 +0000)
since &#37; and just about every other punctuation character is special to
cmd.exe, batch files, and nmake, on Windows.

FossilOrigin-Name: 79a8d3edf8207d72f0c4650272ee239a1c7783a07f907fbf0cf5a7ad99b27a2a

manifest
manifest.uuid
src/shell.c.in
test/shell-prompt.sql

index 166e84b3288b467b0520f7249ba3eb79ac406847..a8ded7e1e75a1d00410ad6dc13488d8428d517a5 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C CLI\sprompt\sdesign\schange:\s\sThe\sescape\scharacter\sis\schanged\sfrom\s&#92;\sto\n%#37;.\s\sThis\savoids\slots\sof\squoting\sproblems\swhen\strying\sto\sspecify\sprompt\nstrings\sin\svarious\sprogramming\slanguages\sand\sshells.
-D 2026-04-11T22:58:25.521
+C Change\sthe\sprompt\sescape\sdesign\syet\sagain,\sto\suse\s/\sas\sthe\sescape\scharacter,\nsince\s&#37;\sand\sjust\sabout\severy\sother\spunctuation\scharacter\sis\sspecial\sto\ncmd.exe,\sbatch\sfiles,\sand\snmake,\son\sWindows.
+D 2026-04-11T23:58:15.898
 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 1984ce045f526350d9d5c896b1cf8016acd46a8f973e493e00d0837db07cbac4
+F src/shell.c.in 10db1d262638901afa657eab2410dd32abe2b3c087179899b5be1bde839baeb2
 F src/sqlite.h.in a5605faa9479bbaac16c4ab43eb09ff50632004a8e05084d3fde56063ef73766
 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 e8fb30de8ad201eeee0ba1f49505974010f1429f46f9e2c01f0dc6a4135f68cb
+F test/shell-prompt.sql 44b4aa9642ad21c11266c2e2c0d4538d40ca7ecf284366e4e20aeda51c6c674f
 F test/shell1.test eda2e527435f139224dda67db6bbd2466597408d4fe5883d647d67fa32d88f7c
 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 6fa0216a19c2f165110121227d3f9b9119369f8cd61f9c6d13eaa1ae42a60d60
-R 5cf6d69f7c518c6e5fa5be100b777a6a
+P e7e6ecc45dfe1a163d259be26877bd7e528ce154e73b3ca8ab7edc5aa94d2d02
+R 1310201927604bb87e94e7f880b7bec1
 U drh
-Z 9c57625d95f1bb2a7bd8171d3c1fac72
+Z c7df6588beeea6afbae61f3c0c7ce22a
 # Remove this line to create a well-formed Fossil manifest.
index 5972c2cae5c49a0229fa3d55060b8e1d1c967c87..991be049516da119069b946daf643a37cfe3a6ab 100644 (file)
@@ -1 +1 @@
-e7e6ecc45dfe1a163d259be26877bd7e528ce154e73b3ca8ab7edc5aa94d2d02
+79a8d3edf8207d72f0c4650272ee239a1c7783a07f907fbf0cf5a7ad99b27a2a
index 551b328fb1f1ac647db255a8b55dbbcbf15a1374..e1c299a1d7f6b80a3a7ae060d8712c9e1e97d8cb 100644 (file)
@@ -911,10 +911,10 @@ static char *local_getline(char *zLine, FILE *in){
 ** The default prompts.
 */
 #ifndef SQLITE_PS1
-# define SQLITE_PS1 "SQLite %f> "
+# define SQLITE_PS1 "SQLite /f> "
 #endif
 #ifndef SQLITE_PS2
-# define SQLITE_PS2 "%B...%H> "
+# define SQLITE_PS2 "/B.../H> "
 #endif
 
 /*
@@ -970,8 +970,11 @@ static const char *prompt_filename(ShellState *p){
 **
 ** Early prototypes use U+005c '\\' as the escape character.  But
 ** that is an escape character for shells and C and many other languages,
-** which can lead to nested quoting problems and confusion.  For that
-** reason, the escape character is changed to U+0025 '%'.
+** which can lead to nested quoting problems and confusion.  The
+** U+0025 '%' character was also tried, and that works pretty well on
+** unix, but % is special to many formats on Windows.  So now we
+** use a forward-slash, U+002f '/', which seems to pass through
+** every shell and "make" without issue.
 */
 static char *expand_prompt(
   ShellState *p,        /* The current shell state */
@@ -984,27 +987,27 @@ static char *expand_prompt(
   int onoff = 1;
   int idxSpace = -1;
   for(i=0; zPrompt[i]; i++){
-    if( zPrompt[i]!='%' ) continue;
+    if( zPrompt[i]!='/' ) continue;
     if( i>0 ){
       if( onoff ) sqlite3_str_append(pOut, zPrompt, i);
       zPrompt += i;
       i = 0;
     }
-    /* At this point zPrompt[0] is a % character and all prior
+    /* At this point zPrompt[0] is a / character and all prior
     ** characters have already been loaded into pOut.  Process the
     ** escape sequence that zPrompt points to. */
     c = zPrompt[1];
     if( c==0 ){
-      /* ~ at the end of a line is silently ignored */
+      /* / at the end of a line is silently ignored */
       break;
     }
-    if( c=='%' ){
-      /* %% maps into a single %  */
+    if( c=='/' ){
+      /* // maps into a single /  */
       zPrompt++;
       continue;
     }
     if( c>='0' && c<='7' ){
-      /* %nnn becomes a single byte given by octal nnn */
+      /* /nnn becomes a single byte given by octal nnn */
       int v = c - '0';
       while( i<=2 && zPrompt[i+1]>='0' && zPrompt[i+1]<='7' ){
         v = v*8 + zPrompt[++i] - '0';
@@ -1015,7 +1018,7 @@ static char *expand_prompt(
       continue;
     }
     if( c=='e' ){
-      /* %e is shorthand for %033 which is U+001B "Escape" */
+      /* /e is shorthand for /033 which is U+001B "Escape" */
       if( onoff ) sqlite3_str_append(pOut, "\033", 1);
       zPrompt += 2;
       i = -1;
@@ -1025,14 +1028,15 @@ static char *expand_prompt(
     /* The intent of the following codes it to provide alternative
     ** text displays depending on whether or not the connection is
     ** currently in a transaction.  Example 1:  Show a "*" before the ">"
-    ** like psql:
+    ** like psql:  (Note:  We encode the "*" as /052 to avoid closing
+    ** out this comment.)
     **
-    **         .prompt 'sqlite%x*%;> '
+    **         .prompt 'sqlite/x/052/;> '
     **
     ** Example 2: Show database filename is blue if not in a transaction,
     ** or red if within a transaction:
     **
-    **         .prompt '%e[1;%x31%:34%;m~f>%e[0m '
+    **         .prompt '/e[1;/x31/:34/;m~f>/e[0m '
     */
     if( c==':' ){
       /* toggle display on/off */
@@ -1049,7 +1053,7 @@ static char *expand_prompt(
       continue;
     }
     if( c=='x' ){
-      /* %x turns display off not in a transaction, on if in txn */
+      /* /x turns display off not in a transaction, on if in txn */
       onoff = p->db && !sqlite3_get_autocommit(p->db);
       zPrompt += 2;
       i = -1;
@@ -1057,9 +1061,9 @@ static char *expand_prompt(
     }
 
     if( c=='f' || c=='F' || c=='~' ){
-      /* %f becomes the tail of the database filename */
-      /* %F becomes the full pathname */
-      /* %~ becomes the full pathname relative to $HOME */
+      /* /f becomes the tail of the database filename */
+      /* /F becomes the full pathname */
+      /* /~ becomes the full pathname relative to $HOME */
       if( onoff ){
         const char *zFN = prompt_filename(p);
         if( c=='f' ){
@@ -1088,7 +1092,7 @@ static char *expand_prompt(
     }
 
     if( c=='H' ){
-      /* %H becomes text needed to terminate current input */
+      /* /H becomes text needed to terminate current input */
       if( onoff ){
         sqlite3_int64 R = zPrior ? sqlite3_incomplete(zPrior) : 0;
         int cc = (R>>16)&0xff;
@@ -1120,8 +1124,8 @@ static char *expand_prompt(
     }
 
     if( c=='B' ){
-      /* %B is a no-op for the main prompt.  For the continuation prompt,
-      ** %B expands to zero or more spaces to make the continuation prompt
+      /* /B is a no-op for the main prompt.  For the continuation prompt,
+      ** /B expands to zero or more spaces to make the continuation prompt
       ** at least as wide as the main prompt. */
       if( onoff ) idxSpace = sqlite3_str_length(pOut);
       zPrompt += 2;
@@ -1130,7 +1134,7 @@ static char *expand_prompt(
     }
 
     /* No match to a known escape.  Generate an error. */
-    if( onoff ) sqlite3_str_appendf(pOut,"UNKNOWN(\"%%%c\")",c);
+    if( onoff ) sqlite3_str_appendf(pOut,"UNKNOWN(\"/%c\")",c);
     zPrompt += 2;
     i = -1;
   }
@@ -1138,7 +1142,7 @@ static char *expand_prompt(
     sqlite3_str_append(pOut, zPrompt, i);
   }
 
-  /* Expand the %B, if there is one and if this is a continuation prompt */
+  /* Expand the /B, if there is one and if this is a continuation prompt */
   if( idxSpace>=0 && zPrior!=0 && zPrior[0]!=0 ){
     char *zOther = expand_prompt(p, 0, prompt_string(p,0));
     size_t wOther = sqlite3_qrf_wcswidth(zOther);
index 4f880899ce2cf910fd061b67d12dba4411fb3af9..697c7504182f4dfd1c650e377d26d7ea5b6d5b6d 100644 (file)
@@ -28,8 +28,8 @@
 .testcase 110
 .prompt --show
 .check <<END
-Main prompt:  'SQLite %f> '
-Continuation: '%B...%H> '
+Main prompt:  'SQLite /f> '
+Continuation: '/B.../H> '
 END
 
 .testcase 1000
@@ -61,7 +61,7 @@ SELECT shell_prompt_test(NULL,'CREATE TRIGGER t1 BEGIN SELECT 1;');
 .check "       ...END;> ";
 
 .testcase 2000
-.prompt 'SQLite%x-txn$%:>%; '
+.prompt 'SQLite/x-txn$/:>/; '
 SELECT shell_prompt_test(NULL);
 .check 'SQLite> ';
 .testcase 2001