diff options
author | drh <> | 2024-10-08 15:11:43 +0000 |
---|---|---|
committer | drh <> | 2024-10-08 15:11:43 +0000 |
commit | ab85d9abd6e5ed5997387c9db31dd6dfaece2681 (patch) | |
tree | 7ff69a2e4accfc9b2e34f5ede736f851cb330751 /src | |
parent | dd2deecbbd03ec1478701b2029479c4983d8fae7 (diff) | |
download | sqlite-ab85d9abd6e5ed5997387c9db31dd6dfaece2681.tar.gz sqlite-ab85d9abd6e5ed5997387c9db31dd6dfaece2681.zip |
Additional improvements to the behavior of ".crnl" in the CLI. The default
output mode is O_BINARY so that results are identical on Windows and
non-Windows systems. On Windows you can optionally do ".crnl on" to enable
NL-to-CRLF conversion on output. Output to Windows console is always
O_U8TEXT and so is unaffected by the .crnl setting.
FossilOrigin-Name: dbfc10b8981bcce4f875c4adef43f398871b41551074445087e343ded50253c5
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c.in | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/shell.c.in b/src/shell.c.in index 0485fb2a2..3f894e973 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -6436,6 +6436,7 @@ static void output_redir(ShellState *p, FILE *pfNew){ sqlite3_fputs("Output already redirected.\n", stderr); }else{ p->out = pfNew; + setCrnlMode(p); if( p->mode==MODE_Www ){ sqlite3_fputs( "<!DOCTYPE html>\n" @@ -6491,6 +6492,7 @@ static void output_reset(ShellState *p){ } p->outfile[0] = 0; p->out = stdout; + setCrnlMode(p); } #else # define output_redir(SS,pfO) @@ -10239,7 +10241,6 @@ static int do_meta_command(char *zLine, ShellState *p){ #ifdef SQLITE_OMIT_POPEN eputz("Error: pipes are not supported in this OS\n"); rc = 1; - p->out = stdout; #else p->in = sqlite3_popen(azArg[1]+1, "r"); if( p->in==0 ){ @@ -12620,6 +12621,14 @@ static void main_init(ShellState *data) { sqlite3_config(SQLITE_CONFIG_MULTITHREAD); sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> "); sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); + + /* By default, come up in O_BINARY mode. That way, the default output is + ** the same for Windows and non-Windows systems. Use the ".crnl on" + ** command to change into O_TEXT mode to do automatic NL-to-CRLF + ** conversions on output for Windows. Windows console output is not + ** subject to the crnlMode setting and is unaffected either way. This + ** setting only affects output going into a file or pipe. */ + data->crnlMode = 0; } /* |