Fossil SCM

Use linenoise for fossil shell. Do not bother with persistent history.

andygoth 2016-11-04 23:57 trunk
Commit 6327b026a866ace35f3f529b5e8f354c17c3f6db
1 file changed +6 -2
+6 -2
--- src/fshell.c
+++ src/fshell.c
@@ -25,10 +25,11 @@
2525
** It allows multiple commands to be issued without having to reenter the
2626
** crypto phasephrase for each command.
2727
*/
2828
#include "config.h"
2929
#include "fshell.h"
30
+#include "linenoise.h"
3031
#include <ctype.h>
3132
3233
#ifndef _WIN32
3334
#include <sys/types.h>
3435
#include <sys/wait.h>
@@ -55,16 +56,19 @@
5556
int mxArg = 0;
5657
int n, i;
5758
char **azArg = 0;
5859
int fDebug;
5960
pid_t childPid;
60
- char zLine[10000];
61
+ char *zLine = 0;
6162
fDebug = find_option("debug", 0, 0)!=0;
6263
db_find_and_open_repository(OPEN_ANY_SCHEMA|OPEN_OK_NOT_FOUND, 0);
6364
db_close(0);
6465
sqlite3_shutdown();
65
- while( printf("fossil> "),fflush(stdout),fgets(zLine, sizeof(zLine), stdin) ){
66
+ while( (free(zLine), zLine = linenoise("fossil> ")) ){
67
+ /* Remember shell history within the current session */
68
+ linenoiseHistoryAdd(zLine);
69
+
6670
/* Parse the line of input */
6771
n = (int)strlen(zLine);
6872
for(i=0, nArg=1; i<n; i++){
6973
while( fossil_isspace(zLine[i]) ){ i++; }
7074
if( i>=n ) break;
7175
--- src/fshell.c
+++ src/fshell.c
@@ -25,10 +25,11 @@
25 ** It allows multiple commands to be issued without having to reenter the
26 ** crypto phasephrase for each command.
27 */
28 #include "config.h"
29 #include "fshell.h"
 
30 #include <ctype.h>
31
32 #ifndef _WIN32
33 #include <sys/types.h>
34 #include <sys/wait.h>
@@ -55,16 +56,19 @@
55 int mxArg = 0;
56 int n, i;
57 char **azArg = 0;
58 int fDebug;
59 pid_t childPid;
60 char zLine[10000];
61 fDebug = find_option("debug", 0, 0)!=0;
62 db_find_and_open_repository(OPEN_ANY_SCHEMA|OPEN_OK_NOT_FOUND, 0);
63 db_close(0);
64 sqlite3_shutdown();
65 while( printf("fossil> "),fflush(stdout),fgets(zLine, sizeof(zLine), stdin) ){
 
 
 
66 /* Parse the line of input */
67 n = (int)strlen(zLine);
68 for(i=0, nArg=1; i<n; i++){
69 while( fossil_isspace(zLine[i]) ){ i++; }
70 if( i>=n ) break;
71
--- src/fshell.c
+++ src/fshell.c
@@ -25,10 +25,11 @@
25 ** It allows multiple commands to be issued without having to reenter the
26 ** crypto phasephrase for each command.
27 */
28 #include "config.h"
29 #include "fshell.h"
30 #include "linenoise.h"
31 #include <ctype.h>
32
33 #ifndef _WIN32
34 #include <sys/types.h>
35 #include <sys/wait.h>
@@ -55,16 +56,19 @@
56 int mxArg = 0;
57 int n, i;
58 char **azArg = 0;
59 int fDebug;
60 pid_t childPid;
61 char *zLine = 0;
62 fDebug = find_option("debug", 0, 0)!=0;
63 db_find_and_open_repository(OPEN_ANY_SCHEMA|OPEN_OK_NOT_FOUND, 0);
64 db_close(0);
65 sqlite3_shutdown();
66 while( (free(zLine), zLine = linenoise("fossil> ")) ){
67 /* Remember shell history within the current session */
68 linenoiseHistoryAdd(zLine);
69
70 /* Parse the line of input */
71 n = (int)strlen(zLine);
72 for(i=0, nArg=1; i<n; i++){
73 while( fossil_isspace(zLine[i]) ){ i++; }
74 if( i>=n ) break;
75

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button