Fossil SCM
Use linenoise for fossil shell. Do not bother with persistent history.
Commit
6327b026a866ace35f3f529b5e8f354c17c3f6db
Parent
bbafc013aa7348f…
1 file changed
+6
-2
+6
-2
| --- src/fshell.c | ||
| +++ src/fshell.c | ||
| @@ -25,10 +25,11 @@ | ||
| 25 | 25 | ** It allows multiple commands to be issued without having to reenter the |
| 26 | 26 | ** crypto phasephrase for each command. |
| 27 | 27 | */ |
| 28 | 28 | #include "config.h" |
| 29 | 29 | #include "fshell.h" |
| 30 | +#include "linenoise.h" | |
| 30 | 31 | #include <ctype.h> |
| 31 | 32 | |
| 32 | 33 | #ifndef _WIN32 |
| 33 | 34 | #include <sys/types.h> |
| 34 | 35 | #include <sys/wait.h> |
| @@ -55,16 +56,19 @@ | ||
| 55 | 56 | int mxArg = 0; |
| 56 | 57 | int n, i; |
| 57 | 58 | char **azArg = 0; |
| 58 | 59 | int fDebug; |
| 59 | 60 | pid_t childPid; |
| 60 | - char zLine[10000]; | |
| 61 | + char *zLine = 0; | |
| 61 | 62 | fDebug = find_option("debug", 0, 0)!=0; |
| 62 | 63 | db_find_and_open_repository(OPEN_ANY_SCHEMA|OPEN_OK_NOT_FOUND, 0); |
| 63 | 64 | db_close(0); |
| 64 | 65 | 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 | + | |
| 66 | 70 | /* Parse the line of input */ |
| 67 | 71 | n = (int)strlen(zLine); |
| 68 | 72 | for(i=0, nArg=1; i<n; i++){ |
| 69 | 73 | while( fossil_isspace(zLine[i]) ){ i++; } |
| 70 | 74 | if( i>=n ) break; |
| 71 | 75 |
| --- 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 |