From 1760545793eb4aa9f29b61510cc8ceaa11c9acd5 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 7 Sep 2016 13:20:29 +0000 Subject: [PATCH] Fix the ".read" command in the command-line shell so that it understands that the input is not interactive. FossilOrigin-Name: 7c2c0d1dceb6b49822e5f5c5e531744d2a4fd12c --- manifest | 15 ++++++++------- manifest.uuid | 2 +- src/shell.c | 4 ++-- test/shell4.test | 13 +++++++++++++ 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index cc89aecb0f..fca724b98a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\snumber\sto\s3.14.2. -D 2016-09-07T12:47:46.925 +C Fix\sthe\s".read"\scommand\sin\sthe\scommand-line\sshell\sso\sthat\sit\sunderstands\nthat\sthe\sinput\sis\snot\sinteractive. +D 2016-09-07T13:20:29.424 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50e36f9aa2c4f8e0a02ba1984d7e81001827d97d @@ -384,7 +384,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 0392c6686586b1d4dac9a4106959f03ddd70e9aa F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 -F src/shell.c 79dda477be6c96eba6e952a934957ad36f87acc7 +F src/shell.c de7c7e98846cacbfbe062cbd98bca899dfb720e3 F src/sqlite.h.in 0f7580280d1b009b507d8beec1ff0f197ba0cc99 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae @@ -1068,7 +1068,7 @@ F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 F test/shell1.test 65b10cd8a90cda9b5af9100a45689a57dcc01a31 F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b F test/shell3.test da513d522ef6f01cee8475dcf8332bff8982b3dd -F test/shell4.test 69995ee1cc278eb149aa8746ce1f935f4eaf98b9 +F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d F test/shell5.test 50a732c1c2158b1cd62cf53975ce1ea7ce6b9dc9 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 @@ -1509,7 +1509,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P af951e036ec7480d04656364fef1c6e24a24b1b2 -R 6e41e85a0ca61605de9fe30d463feb12 +P 925ef2f915c99fa358d988081497dc3a55515816 +Q +d8451fe84d09db6ec7e1bd5f0708ea1b5e85f3d6 +R bb7c8d1dff91c6564d07fbf38ac877d7 U drh -Z ea2fcd0cc2c47cd3cbd22b517a17e16f +Z dcc6177e9e864b7646528523888367fd diff --git a/manifest.uuid b/manifest.uuid index e069620323..e50a39daad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -925ef2f915c99fa358d988081497dc3a55515816 \ No newline at end of file +7c2c0d1dceb6b49822e5f5c5e531744d2a4fd12c \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 18c6ef7197..21cba66b1c 100644 --- a/src/shell.c +++ b/src/shell.c @@ -524,7 +524,7 @@ static char *local_getline(char *zLine, FILE *in){ #if defined(_WIN32) || defined(WIN32) /* For interactive input on Windows systems, translate the ** multi-byte characterset characters into UTF-8. */ - if( stdin_is_interactive ){ + if( stdin_is_interactive && in==stdin ){ char *zTrans = sqlite3_win32_mbcs_to_utf8_v2(zLine, 0); if( zTrans ){ int nTrans = strlen30(zTrans)+1; @@ -4905,7 +4905,7 @@ static int process_input(ShellState *p, FILE *in){ zLine = one_input_line(in, zLine, nSql>0); if( zLine==0 ){ /* End of input */ - if( stdin_is_interactive ) printf("\n"); + if( in==0 && stdin_is_interactive ) printf("\n"); break; } if( seenInterrupt ){ diff --git a/test/shell4.test b/test/shell4.test index 3e4ae55816..88e5e69a28 100644 --- a/test/shell4.test +++ b/test/shell4.test @@ -18,6 +18,7 @@ # # shell4-1.*: Basic tests specific to the "stats" command. # shell4-2.*: Basic tests for ".trace" +# shell4-3.*: The ".read" command takes the shell out of interactive mode # set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -124,5 +125,17 @@ do_test shell4-2.5 { } {0 {SELECT * FROM t1;}} } +do_test shell4-3.1 { + set fd [open t1.txt wb] + puts $fd "SELECT 'squirrel';" + close $fd + exec $::CLI :memory: --interactive ".read t1.txt" +} {squirrel} +do_test shell4-3.2 { + set fd [open t1.txt wb] + puts $fd "SELECT 'pound: \302\243';" + close $fd + exec $::CLI :memory: --interactive ".read t1.txt" +} {pound: £} finish_test -- 2.39.5