diff options
author | drh <> | 2023-02-24 21:23:53 +0000 |
---|---|---|
committer | drh <> | 2023-02-24 21:23:53 +0000 |
commit | 96705c1d7a8d135dc2d9863d1cb2584d192c8e89 (patch) | |
tree | c0a9e86872768c8dd17c2e1ae23248245900d706 /src | |
parent | d8f13f48a8947125bf2a814cbcb3aec90badb1da (diff) | |
download | sqlite-96705c1d7a8d135dc2d9863d1cb2584d192c8e89.tar.gz sqlite-96705c1d7a8d135dc2d9863d1cb2584d192c8e89.zip |
Add the "on" option to the ".log" command in the CLI. Allow ".log on" and
".log off" even in --safe mode. Enable the .log command for fiddle builds.
FossilOrigin-Name: 6bba9100ae81466eeb49845c449cbfddf4f82f18b89f55e6ef575cbf66af63af
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c.in | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/shell.c.in b/src/shell.c.in index 512c3436e..bc3994dd1 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4623,8 +4623,10 @@ static const char *(azHelp[]) = { #if !defined(SQLITE_OMIT_LOAD_EXTENSION) && !defined(SQLITE_SHELL_FIDDLE) ".load FILE ?ENTRY? Load an extension library", #endif -#ifndef SQLITE_SHELL_FIDDLE - ".log FILE|off Turn logging on or off. FILE can be stderr/stdout", +#if !defined(SQLITE_SHELL_FIDDLE) + ".log FILE|on|off Turn logging on or off. FILE can be stderr/stdout", +#else + ".log on|off Turn logging on or off.", #endif ".mode MODE ?OPTIONS? Set output mode", " MODE is one of:", @@ -9113,19 +9115,25 @@ static int do_meta_command(char *zLine, ShellState *p){ }else #endif -#ifndef SQLITE_SHELL_FIDDLE if( c=='l' && cli_strncmp(azArg[0], "log", n)==0 ){ - failIfSafeMode(p, "cannot run .log in safe mode"); if( nArg!=2 ){ raw_printf(stderr, "Usage: .log FILENAME\n"); rc = 1; }else{ const char *zFile = azArg[1]; + if( p->bSafeMode + && cli_strcmp(zFile,"on")!=0 + && cli_strcmp(zFile,"off")!=0 + ){ + raw_printf(stdout, "cannot set .log to anything other " + "than \"on\" or \"off\"\n"); + zFile = "off"; + } output_file_close(p->pLog); + if( cli_strcmp(zFile,"on")==0 ) zFile = "stdout"; p->pLog = output_file_open(zFile, 0); } }else -#endif if( c=='m' && cli_strncmp(azArg[0], "mode", n)==0 ){ const char *zMode = 0; |