From 47ad6840f5cd213349794e7d691d9dfd83d51775 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 8 Nov 2006 12:25:42 +0000 Subject: [PATCH] Make the .exit and .quit commands work again in the shell. Ticket #2056. (CVS 3505) FossilOrigin-Name: f39978ef13e986a16ee322ee84ab9bd38ffc5a8b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 19 +++++++++++++------ 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 9dee6af158..e110c5c422 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stypo\sin\sos_win.c.\s\sTicket\s#2055.\s(CVS\s3504) -D 2006-11-07T15:02:08 +C Make\sthe\s.exit\sand\s.quit\scommands\swork\sagain\sin\sthe\sshell.\s\sTicket\s#2056.\s(CVS\s3505) +D 2006-11-08T12:25:43 F Makefile.in 8e14898d41a53033ecb687d93c9cd5d109fb9ae3 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -94,7 +94,7 @@ F src/printf.c b179b6ed12f793e028dd169e2e2e2b2a37eedc63 F src/random.c d40f8d356cecbd351ccfab6eaedd7ec1b54f5261 F src/select.c 6ba6d8ead43d0575ce1f8b418cc039f8f301389a F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96 -F src/shell.c e5bda308495ed580600c12325dc2007f74f85058 +F src/shell.c 41513f31dce4252198944c712b79ea4c92df2592 F src/sqlite.h.in bf935004029631fd93d119bcf2f7259b9cb9ad5e F src/sqlite3ext.h 2c2156cc32a158e2b7bd9042d42accf94bff2e40 F src/sqliteInt.h 637ef229c3d8e0f98096ab31c496efdf5361d678 @@ -419,7 +419,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P 6324ea811eec1200cee89e6f377368eaf2fcda77 -R f7c488c391f8a54609e362ee14ba86d3 +P d309680ec7a806d181b601e0105aebf1e33bfb81 +R e590c00bb49173f4e5a5df7e97598d24 U drh -Z 7b5d97e736ec81b95b9a8c1109b28cf7 +Z 928b8f12ac488a19e769eda3ed1d6f5a diff --git a/manifest.uuid b/manifest.uuid index 58e4626444..93dcfe1279 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d309680ec7a806d181b601e0105aebf1e33bfb81 \ No newline at end of file +f39978ef13e986a16ee322ee84ab9bd38ffc5a8b \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 099104a874..1b59788600 100644 --- a/src/shell.c +++ b/src/shell.c @@ -12,7 +12,7 @@ ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** -** $Id: shell.c,v 1.154 2006/10/31 18:08:28 drh Exp $ +** $Id: shell.c,v 1.155 2006/11/08 12:25:43 drh Exp $ */ #include #include @@ -918,7 +918,7 @@ static int booleanValue(char *zArg){ ** If an input line begins with "." then invoke this routine to ** process that line. ** -** Return 1 to exit and 0 to continue. +** Return 1 on error, 2 to exit, and 0 otherwise. */ static int do_meta_command(char *zLine, struct callback_data *p){ int i = 1; @@ -1026,7 +1026,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ }else if( c=='e' && strncmp(azArg[0], "exit", n)==0 ){ - rc = 1; + rc = 2; }else if( c=='e' && strncmp(azArg[0], "explain", n)==0 ){ @@ -1100,6 +1100,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ if( rc ){ fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db)); nCol = 0; + rc = 1; }else{ nCol = sqlite3_column_count(pStmt); } @@ -1120,7 +1121,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ if( rc ){ fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db)); sqlite3_finalize(pStmt); - return 0; + return 1; } in = fopen(zFile, "rb"); if( in==0 ){ @@ -1166,6 +1167,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ if( rc!=SQLITE_OK ){ fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db)); zCommit = "ROLLBACK"; + rc = 1; break; } } @@ -1211,6 +1213,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ if( rc!=SQLITE_OK ){ fprintf(stderr, "%s\n", zErrMsg); sqlite3_free(zErrMsg); + rc = 1; } }else #endif @@ -1282,7 +1285,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ }else if( c=='q' && strncmp(azArg[0], "quit", n)==0 ){ - rc = 1; + rc = 2; }else if( c=='r' && strncmp(azArg[0], "read", n)==0 && nArg==2 ){ @@ -1434,6 +1437,8 @@ static int do_meta_command(char *zLine, struct callback_data *p){ } printf("\n"); } + }else{ + rc = 1; } sqlite3_free_table(azResult); }else @@ -1542,7 +1547,9 @@ static int process_input(struct callback_data *p, FILE *in){ if( zLine && zLine[0]=='.' && nSql==0 ){ rc = do_meta_command(zLine, p); free(zLine); - if( rc ){ + if( rc==2 ){ + break; + }else if( rc ){ errCnt++; } continue;