diff options
author | drh <> | 2021-02-17 13:19:22 +0000 |
---|---|---|
committer | drh <> | 2021-02-17 13:19:22 +0000 |
commit | 4b0229ae1ff30df9cf1d33e7c1df27cb01c5ecfe (patch) | |
tree | d79d53a9bd67e4a03b661c5bd6db44630759fdb9 /src | |
parent | 6b37b762ed85f83d4b78d60fdd97b36c40de887f (diff) | |
download | sqlite-4b0229ae1ff30df9cf1d33e7c1df27cb01c5ecfe.tar.gz sqlite-4b0229ae1ff30df9cf1d33e7c1df27cb01c5ecfe.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c.in | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/shell.c.in b/src/shell.c.in index bfb964812..03c4fd319 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+1<nArg ) zFile = sqlite3_mprintf("%z %s", zFile, azArg[++i]); + break; + } }else{ utf8_printf(p->out,"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 ){ |