-C Updated\sto\smatch\snew\sshell.c\sfunctionality.\s(CVS\s533)
-D 2002-04-18T02:53:54
+C Change\sshell.c\sso\sthat\sit\swill\scompile\sunder\swindows.\s\sShorten\sthe\shelp\ncommand\ssomewhat.\s\sAdd\sthe\sstate\sof\s".header"\sto\sthe\soutput\sof\s".show".\s(CVS\s534)
+D 2002-04-18T12:39:03
F Makefile.in 50f1b3351df109b5774771350d8c1b8d3640130d
F Makefile.template 89e373b2dad0321df00400fa968dc14b61a03296
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
F src/printf.c 300a90554345751f26e1fc0c0333b90a66110a1d
F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe
F src/select.c 92aef3f69e90dc065d680d88b1f075409e9249bb
-F src/shell.c e473e19509c5c9b02bb2fb674be4b223cb052334
+F src/shell.c 4a225aa846f494488d9bab324b68749d25a890b7
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
F src/sqlite.h.in ffcacf73b5ed1a4939205d29a704a185758fa6a6
F src/sqliteInt.h e47ca9267a4c4a98e9f8d90c2df994a18f23d699
F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P 4bdd040e4810565c91bcbb5f065580520c5e3c45
-R fccec3c1f56efdafc771baab879ce3fe
-U persicom
-Z f4c9300a9a77dcec47079904c2bfe5db
+P ff67ad40106a20fb85797cca4c495dc34ad5519b
+R 83edff024b8dcab1f99c47b3727e4d20
+U drh
+Z 1f0ab834158fafdf0840052f540be94f
** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases.
**
-** $Id: shell.c,v 1.52 2002/04/18 02:53:05 persicom Exp $
+** $Id: shell.c,v 1.53 2002/04/18 12:39:03 drh Exp $
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "sqlite.h"
#include <ctype.h>
-#include <pwd.h>
-#include <sys/types.h>
#if !defined(_WIN32) && !defined(WIN32)
# include <signal.h>
+# include <pwd.h>
+# include <unistd.h>
+# include <sys/types.h>
#endif
#if defined(HAVE_READLINE) && HAVE_READLINE==1
".echo ON|OFF Turn command echo on or off\n"
".exit Exit this program\n"
".explain ON|OFF Turn output mode suitable for EXPLAIN on or off.\n"
- " \"off\" will revert to the output mode that was\n"
- " previously in effect\n"
".header(s) ON|OFF Turn display of headers on or off\n"
".help Show this message\n"
".indices TABLE Show names of all indices on TABLE\n"
".output FILENAME Send output to FILENAME\n"
".output stdout Send output to the screen\n"
".prompt MAIN CONTINUE Replace the standard prompts\n"
- " \"sqlite > \" and \" ...> \"\n"
- " with the strings MAIN and CONTINUE\n"
- " CONTINUE is optional.\n"
".quit Exit this program\n"
".read FILENAME Execute SQL in FILENAME\n"
".reindex ?TABLE? Rebuild indices\n"
/* ".rename OLD NEW Change the name of a table or index\n" */
".schema ?TABLE? Show the CREATE statements\n"
".separator STRING Change separator string for \"list\" mode\n"
- ".show Show the current values for the following:\n"
- " .echo\n"
- " .explain\n"
- " .mode\n"
- " .nullvalue\n"
- " .output\n"
- " .separator\n"
- " .width\n"
+ ".show Show the current values for various settings\n"
".tables ?PATTERN? List names of tables matching a pattern\n"
".timeout MS Try opening locked tables for MS milliseconds\n"
".width NUM NUM ... Set column widths for \"column\" mode\n"
exit(0);
}else
- if( c=='e' && strncmp(azArg[0], "explain", n)==0 && nArg>1){
+ if( c=='e' && strncmp(azArg[0], "explain", n)==0 ){
int j;
- char *z = azArg[1];
- int val = atoi(azArg[1]);
+ char *z = nArg>=2 ? azArg[1] : "1";
+ int val = atoi(z);
for(j=0; z[j]; j++){
if( isupper(z[j]) ) z[j] = tolower(z[j]);
}
}
}else
- if( c=='p' && strncmp(azArg[0], "prompt", n)==0 && nArg==2 || nArg==3){
+ if( c=='p' && strncmp(azArg[0], "prompt", n)==0 && (nArg==2 || nArg==3)){
if( nArg >= 2) {
strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);
}
int i;
fprintf(p->out,"%9.9s: %s\n","echo", p->echoOn ? "on" : "off");
fprintf(p->out,"%9.9s: %s\n","explain", p->explainPrev.valid ? "on" : "off");
+ fprintf(p->out,"%9.9s: %s\n","headers", p->showHeader ? "on" : "off");
fprintf(p->out,"%9.9s: %s\n","mode", modeDescr[p->mode]);
fprintf(p->out,"%9.9s: %s\n","nullvalue", p->nullvalue);
fprintf(p->out,"%9.9s: %s\n","output", strlen(p->outfile) ? p->outfile : "stdout");
char *home_dir = NULL;
char *sqliterc = sqliterc_override;
- struct passwd *pwent;
- uid_t uid = getuid();
FILE *in = NULL;
if (sqliterc == NULL) {
/* Figure out the user's home directory */
+#if !defined(_WIN32) && !defined(WIN32)
+ struct passwd *pwent;
+ uid_t uid = getuid();
while( (pwent=getpwent()) != NULL) {
if(pwent->pw_uid == uid) {
home_dir = pwent->pw_dir;
break;
}
}
+#endif
if (!home_dir) {
home_dir = getenv("HOME");
} else {
printf("Loading resources from %s\n",sqliterc);
process_input(p,in);
- close (in);
+ fclose(in);
}
return;
}