mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-03 16:53:36 +03:00
Add the ".shell" and the ".system" commands (aliases for the same thing)
to the command-line shell. FossilOrigin-Name: d018a34a05cec6adda61ed225d084c587343f2a6
This commit is contained in:
19
src/shell.c
19
src/shell.c
@@ -1580,7 +1580,7 @@ static char zHelp[] =
|
||||
".exit Exit this program\n"
|
||||
".explain ?ON|OFF? Turn output mode suitable for EXPLAIN on or off.\n"
|
||||
" With no args, it turns EXPLAIN on.\n"
|
||||
".header(s) ON|OFF Turn display of headers on or off\n"
|
||||
".headers ON|OFF Turn display of headers on or off\n"
|
||||
".help Show this message\n"
|
||||
".import FILE TABLE Import data from FILE into TABLE\n"
|
||||
".indices ?TABLE? Show names of all indices\n"
|
||||
@@ -1616,8 +1616,10 @@ static char zHelp[] =
|
||||
" If TABLE specified, only show tables matching\n"
|
||||
" LIKE pattern TABLE.\n"
|
||||
".separator STRING Change separator used by output mode and .import\n"
|
||||
".shell CMD ARGS... Run CMD ARGS... in a system shell\n"
|
||||
".show Show the current values for various settings\n"
|
||||
".stats ON|OFF Turn stats on or off\n"
|
||||
".system CMD ARGS... Run CMD ARGS... in a system shell\n"
|
||||
".tables ?TABLE? List names of tables\n"
|
||||
" If TABLE specified, only list tables matching\n"
|
||||
" LIKE pattern TABLE.\n"
|
||||
@@ -1625,6 +1627,7 @@ static char zHelp[] =
|
||||
".trace FILE|off Output each SQL statement as it is run\n"
|
||||
".vfsname ?AUX? Print the name of the VFS stack\n"
|
||||
".width NUM1 NUM2 ... Set column widths for \"column\" mode\n"
|
||||
" Negative values right-justify\n"
|
||||
;
|
||||
|
||||
static char zTimerHelp[] =
|
||||
@@ -2900,6 +2903,20 @@ static int do_meta_command(char *zLine, struct callback_data *p){
|
||||
"%.*s", (int)sizeof(p->separator)-1, azArg[1]);
|
||||
}else
|
||||
|
||||
if( c=='s'
|
||||
&& (strncmp(azArg[0], "shell", n)==0 || strncmp(azArg[0],"system",n)==0)
|
||||
&& nArg>=2
|
||||
){
|
||||
char *zCmd;
|
||||
int i;
|
||||
zCmd = sqlite3_mprintf("\"%s\"", azArg[1]);
|
||||
for(i=2; i<nArg; i++){
|
||||
zCmd = sqlite3_mprintf("%z \"%s\"", zCmd, azArg[i]);
|
||||
}
|
||||
system(zCmd);
|
||||
sqlite3_free(zCmd);
|
||||
}else
|
||||
|
||||
if( c=='s' && strncmp(azArg[0], "show", n)==0 && nArg==1 ){
|
||||
int i;
|
||||
fprintf(p->out,"%9.9s: %s\n","echo", p->echoOn ? "on" : "off");
|
||||
|
||||
Reference in New Issue
Block a user