/ Check-in [5fe28e15]
Login

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

Overview
Comment:Add the ".cd" command to the command-line shell.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5fe28e15b1d6d8a588fcaf93c6035c0e0ab7bcad1067c7933cd430d2e04bbbd8
User & Date: drh 2017-05-22 18:00:34
Context
2017-05-22
18:09
Fix incompatibilities between the "sqldiff --changeset" command and the sessions module. Specifically, allow sessions to process changesets containing tables with zero operations on them and have sqldiff output the expected output for tables with multi-column primary keys. check-in: 0bb23c48 user: dan tags: trunk
18:00
Add the ".cd" command to the command-line shell. check-in: 5fe28e15 user: drh tags: trunk
17:39
Increase the version number to 3.20 for the next release cycle. check-in: ab471f61 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

  3230   3230   static char zHelp[] =
  3231   3231   #ifndef SQLITE_OMIT_AUTHORIZATION
  3232   3232     ".auth ON|OFF           Show authorizer callbacks\n"
  3233   3233   #endif
  3234   3234     ".backup ?DB? FILE      Backup DB (default \"main\") to FILE\n"
  3235   3235     ".bail on|off           Stop after hitting an error.  Default OFF\n"
  3236   3236     ".binary on|off         Turn binary output on or off.  Default OFF\n"
         3237  +  ".cd DIRECTORY          Change the working directory to DIRECTORY\n"
  3237   3238     ".changes on|off        Show number of rows changed by SQL\n"
  3238   3239     ".check GLOB            Fail if output since .testcase does not match\n"
  3239   3240     ".clone NEWDB           Clone data into NEWDB from the existing database\n"
  3240   3241     ".databases             List names and files of attached databases\n"
  3241   3242     ".dbinfo ?DB?           Show status information about the database\n"
  3242   3243     ".dump ?TABLE? ...      Dump the database in an SQL text format\n"
  3243   3244     "                         If TABLE specified, only dump tables matching\n"
................................................................................
  4726   4727           setTextMode(p->out, 1);
  4727   4728         }
  4728   4729       }else{
  4729   4730         raw_printf(stderr, "Usage: .binary on|off\n");
  4730   4731         rc = 1;
  4731   4732       }
  4732   4733     }else
         4734  +
         4735  +  if( c=='c' && strcmp(azArg[0],"cd")==0 ){
         4736  +    if( nArg==2 ){
         4737  +#if defined(_WIN32) || defined(WIN32)
         4738  +      wchar_t *z = sqlite3_win32_utf8_to_unicode(azArg[1]);
         4739  +      rc = !SetCurrentDirectoryW(z);
         4740  +      sqlite3_free(z);
         4741  +#else
         4742  +      rc = chdir(azArg[1]);
         4743  +#endif
         4744  +      if( rc ){
         4745  +        utf8_printf(stderr, "Cannot change to directory \"%s\"\n", azArg[1]);
         4746  +        rc = 1;
         4747  +      }
         4748  +    }else{
         4749  +      raw_printf(stderr, "Usage: .cd DIRECTORY\n");
         4750  +      rc = 1;
         4751  +    }
         4752  +  }else
  4733   4753   
  4734   4754     /* The undocumented ".breakpoint" command causes a call to the no-op
  4735   4755     ** routine named test_breakpoint().
  4736   4756     */
  4737   4757     if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){
  4738   4758       test_breakpoint();
  4739   4759     }else