/ Check-in [d018a34a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the ".shell" and the ".system" commands (aliases for the same thing) to the command-line shell.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d018a34a05cec6adda61ed225d084c587343f2a6
User & Date: drh 2014-05-28 20:22:28
Context
2014-05-29
03:17
Only quote the arguments to the ".shell" and ".system" commands if they contain spaces. check-in: e58f4bd3 user: drh tags: trunk
2014-05-28
20:22
Add the ".shell" and the ".system" commands (aliases for the same thing) to the command-line shell. check-in: d018a34a user: drh tags: trunk
10:00
Add an extra test to verify that the FTS notindexed option is working. check-in: c461c0fe user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

  1576   1576     ".dump ?TABLE? ...      Dump the database in an SQL text format\n"
  1577   1577     "                         If TABLE specified, only dump tables matching\n"
  1578   1578     "                         LIKE pattern TABLE.\n"
  1579   1579     ".echo ON|OFF           Turn command echo on or off\n"
  1580   1580     ".exit                  Exit this program\n"
  1581   1581     ".explain ?ON|OFF?      Turn output mode suitable for EXPLAIN on or off.\n"
  1582   1582     "                         With no args, it turns EXPLAIN on.\n"
  1583         -  ".header(s) ON|OFF      Turn display of headers on or off\n"
         1583  +  ".headers ON|OFF        Turn display of headers on or off\n"
  1584   1584     ".help                  Show this message\n"
  1585   1585     ".import FILE TABLE     Import data from FILE into TABLE\n"
  1586   1586     ".indices ?TABLE?       Show names of all indices\n"
  1587   1587     "                         If TABLE specified, only show indices for tables\n"
  1588   1588     "                         matching LIKE pattern TABLE.\n"
  1589   1589   #ifdef SQLITE_ENABLE_IOTRACE
  1590   1590     ".iotrace FILE          Enable I/O diagnostic logging to FILE\n"
................................................................................
  1612   1612     ".read FILENAME         Execute SQL in FILENAME\n"
  1613   1613     ".restore ?DB? FILE     Restore content of DB (default \"main\") from FILE\n"
  1614   1614     ".save FILE             Write in-memory database into FILE\n"
  1615   1615     ".schema ?TABLE?        Show the CREATE statements\n"
  1616   1616     "                         If TABLE specified, only show tables matching\n"
  1617   1617     "                         LIKE pattern TABLE.\n"
  1618   1618     ".separator STRING      Change separator used by output mode and .import\n"
         1619  +  ".shell CMD ARGS...     Run CMD ARGS... in a system shell\n"
  1619   1620     ".show                  Show the current values for various settings\n"
  1620   1621     ".stats ON|OFF          Turn stats on or off\n"
         1622  +  ".system CMD ARGS...    Run CMD ARGS... in a system shell\n"
  1621   1623     ".tables ?TABLE?        List names of tables\n"
  1622   1624     "                         If TABLE specified, only list tables matching\n"
  1623   1625     "                         LIKE pattern TABLE.\n"
  1624   1626     ".timeout MS            Try opening locked tables for MS milliseconds\n"
  1625   1627     ".trace FILE|off        Output each SQL statement as it is run\n"
  1626   1628     ".vfsname ?AUX?         Print the name of the VFS stack\n"
  1627   1629     ".width NUM1 NUM2 ...   Set column widths for \"column\" mode\n"
         1630  +  "                         Negative values right-justify\n"
  1628   1631   ;
  1629   1632   
  1630   1633   static char zTimerHelp[] =
  1631   1634     ".timer ON|OFF          Turn the CPU timer measurement on or off\n"
  1632   1635   ;
  1633   1636   
  1634   1637   /* Forward reference */
................................................................................
  2895   2898     }else
  2896   2899   #endif
  2897   2900   
  2898   2901     if( c=='s' && strncmp(azArg[0], "separator", n)==0 && nArg==2 ){
  2899   2902       sqlite3_snprintf(sizeof(p->separator), p->separator,
  2900   2903                        "%.*s", (int)sizeof(p->separator)-1, azArg[1]);
  2901   2904     }else
         2905  +
         2906  +  if( c=='s'
         2907  +   && (strncmp(azArg[0], "shell", n)==0 || strncmp(azArg[0],"system",n)==0)
         2908  +   && nArg>=2
         2909  +  ){
         2910  +    char *zCmd;
         2911  +    int i;
         2912  +    zCmd = sqlite3_mprintf("\"%s\"", azArg[1]);
         2913  +    for(i=2; i<nArg; i++){
         2914  +      zCmd = sqlite3_mprintf("%z \"%s\"", zCmd, azArg[i]);
         2915  +    }
         2916  +    system(zCmd);
         2917  +    sqlite3_free(zCmd);
         2918  +  }else
  2902   2919   
  2903   2920     if( c=='s' && strncmp(azArg[0], "show", n)==0 && nArg==1 ){
  2904   2921       int i;
  2905   2922       fprintf(p->out,"%9.9s: %s\n","echo", p->echoOn ? "on" : "off");
  2906   2923       fprintf(p->out,"%9.9s: %s\n","eqp", p->autoEQP ? "on" : "off");
  2907   2924       fprintf(p->out,"%9.9s: %s\n","explain", p->explainPrev.valid ? "on" :"off");
  2908   2925       fprintf(p->out,"%9.9s: %s\n","headers", p->showHeader ? "on" : "off");