sqlite 3.34 Command-line editor
(1.1) By Trudge on 2021-01-06 16:47:43 edited from 1.0 [link] [source]
I've posted this issue previously but had no results, so trying again with a different title.
I work on an old iMac 10.13.6 (High Sierra) and sqlite3 is a system-installed application. However I installed a newer version (3.34) but am having some issues with navigating a command-line - moving left and/or right through the line.
Previously I could use Alt-left arrow or Alt-right arrow to move quickly from one word to another.
With this new version that does not work, but gives me a series of 'bbbbb' or 'fffff' and does NOT move my cursor.
My shell is bash if that makes any difference, but I don't know if that is the issue.
Has anyone else had the same experience, or does anyone have a solution please?
(2) By Larry Brasfield (LarryBrasfield) on 2021-01-06 17:34:40 in reply to 1.1 [link] [source]
One solution is to build the shell with HAVE_READLINE preprocessor symbol set to 1, and link with the readline library.
Another solution would be to use control-left_arrow and control-right_arrow instead of the Alt qualified keys. (After all, the Mac has no Alt key, right?)
(3) By anonymous on 2021-01-06 18:02:21 in reply to 2 [source]
On Windows (which has the Alt key), it is Ctrl + Left | Right arrow.
(4) By Trudge on 2021-01-06 19:01:35 in reply to 2 [link] [source]
Thank you for the build suggestion, but I'm not familiar with building from source code. I had hoped this could be something done with some minor settings.
And yes, the Mac does have an Alt key, aka 'Option', which is how those 'bbbb' got added to the end of the command line. Control-left arrow/right arrow opens up Launchpad on my Mac.
(5) By Larry Brasfield (LarryBrasfield) on 2021-01-06 19:09:44 in reply to 4 [link] [source]
It's not hard to build the shell from the amalgamation. Tips are here, including an example that includes and uses the readline library.
(6) By Trudge on 2021-01-06 19:29:02 in reply to 5 [link] [source]
OK, I gave compiling a whirl but got an error:
~/Downloads/sqlite-amalgamation-3340000 [user] gcc -HAVE_READLINE=1 shell.c sqlite3.c -lpthread -ldl clang: error: unknown argument: '-HAVE_READLINE=1'
(7.2) By Larry Brasfield (LarryBrasfield) on 2021-01-06 19:38:15 edited from 7.1 in reply to 6 [link] [source]
change that to -DHAVE_READLINE=1 .
Also, per the example I cited, add a -lreadline and a -lncurses to the gcc invocation.
(8) By Trudge on 2021-01-06 19:48:10 in reply to 7.2 [link] [source]
Yes I discovered that from reading a little further. This worked for me:
~/Downloads/sqlite-amalgamation-3340000 [user] gcc -DHAVE_READLINE=1 shell.c sqlite3.c -lpthread -ldl -lreadline -lncurses -o sqlite3 2021-01-06 14:37:25 ~/Downloads/sqlite-amalgamation-3340000 [user] sqlite3 /Volumes/femto/FemtoDocuments/MyDB/kba.db SQLite version 3.19.3 2017-06-27 16:48:08 Enter ".help" for usage hints.
Thank you very much. I may be a Perl programmer but that is an interpreted language so I've never had to deal with compiling, linking, etc. in a Mac environment. Many, many years ago I worked with Turbo Pascal on a Windows box. What a great language.