From: drh <> Date: Wed, 17 Feb 2021 13:19:22 +0000 (+0000) Subject: Enhance the ".once" and ".output" commands in the CLI so that if the X-Git-Tag: version-3.35.0~90 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4b0229ae1ff30df9cf1d33e7c1df27cb01c5ecfe;p=thirdparty%2Fsqlite.git Enhance the ".once" and ".output" commands in the CLI so that if the filename argument begins with "|" the name becomes the concatenation of all subsequent arguments. Hence, commands like ".once | open -f" become possible without the need for quotes. FossilOrigin-Name: c46a94a624c2cc6c49ac916a206a913081e1628c24805987cabc75c9057ea36b --- diff --git a/manifest b/manifest index 931f661935..e7f230bfd2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplification\sto\sthe\sresolveAlias()\sroutine. -D 2021-02-16T20:32:17.668 +C Enhance\sthe\s".once"\sand\s".output"\scommands\sin\sthe\sCLI\sso\sthat\sif\sthe\nfilename\sargument\sbegins\swith\s"|"\sthe\sname\sbecomes\sthe\sconcatenation\nof\sall\ssubsequent\sarguments.\s\sHence,\scommands\slike\s".once\s|\sopen\s-f"\sbecome\npossible\swithout\sthe\sneed\sfor\squotes. +D 2021-02-17T13:19:22.550 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -542,7 +542,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c 172d0f27c021b1d572e73b6f04f3e2695f2932233d3f5e675bd85b028fa2fb75 F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92 F src/select.c d009aafcd9304b8406809fc808ce8c2cd55471552d242b98bd3006d0ad55cd12 -F src/shell.c.in 9ebc74e4f05cfbd0f4a36060fdaeff1da4e9af4458358722bc08c5a1ab9a0879 +F src/shell.c.in 844417f84df1f6c4fce1c815629a888cfdcf219e86513e9c332bbcc38832f477 F src/sqlite.h.in 8855a19f37ade8dad189a9e48233a2ebe1b46faf469c7eb0906a654e252dcc57 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 61b38c073d5e1e96a3d45271b257aef27d0d13da2bea5347692ae579475cd95e @@ -1900,7 +1900,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7c03ce49b74f72b63dd75c3a02625e671bfd771f71b24e808994322b00d97677 -R 1b54c7cb4db039e6ced5272704b39604 +P 00bead3931135af80475c22f08cbb26c914518e8f2c7e73c2b8be1cee4ac4d5e +R c958a1f70e224efabdacd339f843bfe0 U drh -Z 6cadfbe2d2e5d960db064c83d646ea7d +Z 21b3dfef27853d212520b4c1b1451b1a diff --git a/manifest.uuid b/manifest.uuid index 10192cda7d..323618e653 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -00bead3931135af80475c22f08cbb26c914518e8f2c7e73c2b8be1cee4ac4d5e \ No newline at end of file +c46a94a624c2cc6c49ac916a206a913081e1628c24805987cabc75c9057ea36b \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index bfb9648128..03c4fd319e 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -8753,7 +8753,7 @@ static int do_meta_command(char *zLine, ShellState *p){ && (strncmp(azArg[0], "output", n)==0||strncmp(azArg[0], "once", n)==0)) || (c=='e' && n==5 && strcmp(azArg[0],"excel")==0) ){ - const char *zFile = 0; + char *zFile = 0; int bTxtMode = 0; int i; int eMode = 0; @@ -8783,17 +8783,22 @@ static int do_meta_command(char *zLine, ShellState *p){ rc = 1; goto meta_command_exit; } - }else if( zFile==0 ){ - zFile = z; + }else if( zFile==0 && eMode!='e' && eMode!='x' ){ + zFile = sqlite3_mprintf("%s", z); + if( zFile[0]=='|' ){ + while( i+1out,"ERROR: extra parameter: \"%s\". Usage:\n", azArg[i]); showHelp(p->out, azArg[0]); rc = 1; + sqlite3_free(zFile); goto meta_command_exit; } } - if( zFile==0 ) zFile = "stdout"; + if( zFile==0 ) zFile = sqlite3_mprintf("stdout"); if( bOnce ){ p->outCount = 2; }else{ @@ -8816,7 +8821,8 @@ static int do_meta_command(char *zLine, ShellState *p){ newTempFile(p, "txt"); bTxtMode = 1; } - zFile = p->zTempFile; + sqlite3_free(zFile); + zFile = sqlite3_mprintf("%s", p->zTempFile); } #endif /* SQLITE_NOHAVE_SYSTEM */ if( zFile[0]=='|' ){ @@ -8848,6 +8854,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", zFile); } } + sqlite3_free(zFile); }else if( c=='p' && n>=3 && strncmp(azArg[0], "parameter", n)==0 ){