SQLite

Check-in [33841c9c]
Login

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

Overview
Comment:In the CLI, if the XDG_CONFIG_HOME environment variable is not set, then also search in ~/.config/sqlite3/sqliterc for the initialization file. See forum thread 5cc6d059e9e092ed.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 33841c9c3cb57beeb3884d4b0715d26199926b7d3e4d3dd1ab6f5603b5a62591
User & Date: drh 2024-07-02 11:30:10
Context
2024-07-02
12:16
Rework the deliberate_fall_through macro along the lines suggested by forum post 7ec11023dd so that it works better with LLVM, while preserving compatibility with MSVC and older GCCs. (check-in: fc248a4a user: drh tags: trunk)
11:30
In the CLI, if the XDG_CONFIG_HOME environment variable is not set, then also search in ~/.config/sqlite3/sqliterc for the initialization file. See forum thread 5cc6d059e9e092ed. (check-in: 33841c9c user: drh tags: trunk)
2024-06-29
15:57
Fix a typo in a comment in a test case. No changes to code. (check-in: f501166d user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/shell.c.in.
11970
11971
11972
11973
11974
11975
11976
11977


11978


11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994

11995

11996
11997

11998
11999
12000
12001
12002
12003
12004

  return home_dir;
}

/*
** On non-Windows platforms, look for $XDG_CONFIG_HOME.
** If ${XDG_CONFIG_HOME}/sqlite3/sqliterc is found, return
** the path to it, else return 0. The result is cached for


** subsequent calls.


*/
static const char *find_xdg_config(void){
#if defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE) \
     || defined(__RTP__) || defined(_WRS_KERNEL)
  return 0;
#else
  static int alreadyTried = 0;
  static char *zConfig = 0;
  const char *zXdgHome;

  if( alreadyTried!=0 ){
    return zConfig;
  }
  alreadyTried = 1;
  zXdgHome = getenv("XDG_CONFIG_HOME");
  if( zXdgHome==0 ){

    return 0;

  }
  zConfig = sqlite3_mprintf("%s/sqlite3/sqliterc", zXdgHome);

  shell_check_oom(zConfig);
  if( access(zConfig,0)!=0 ){
    sqlite3_free(zConfig);
    zConfig = 0;
  }
  return zConfig;
#endif







|
>
>
|
>
>

|




<
|


<
<
<
<


>
|
>
|
|
>







11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988

11989
11990
11991




11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006

  return home_dir;
}

/*
** On non-Windows platforms, look for $XDG_CONFIG_HOME.
** If ${XDG_CONFIG_HOME}/sqlite3/sqliterc is found, return
** the path to it.  If there is no $(XDG_CONFIG_HOME) then
** look for $(HOME)/.config/sqlite3/sqliterc and if found
** return that.  If none of these are found, return 0.
**
** The string returned is obtained from sqlite3_malloc() and
** should be freed by the caller.
*/
static char *find_xdg_config(void){
#if defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE) \
     || defined(__RTP__) || defined(_WRS_KERNEL)
  return 0;
#else

  char *zConfig = 0;
  const char *zXdgHome;





  zXdgHome = getenv("XDG_CONFIG_HOME");
  if( zXdgHome==0 ){
    const char *zHome = getenv("HOME");
    if( zHome==0 ) return 0;
    zConfig = sqlite3_mprintf("%s/.config/sqlite3/sqliterc", zHome);
  }else{
    zConfig = sqlite3_mprintf("%s/sqlite3/sqliterc", zXdgHome);
  }
  shell_check_oom(zConfig);
  if( access(zConfig,0)!=0 ){
    sqlite3_free(zConfig);
    zConfig = 0;
  }
  return zConfig;
#endif
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
  char *home_dir = NULL;
  const char *sqliterc = sqliterc_override;
  char *zBuf = 0;
  FILE *inSaved = p->in;
  int savedLineno = p->lineno;

  if( sqliterc == NULL ){
    sqliterc = find_xdg_config();
  }
  if( sqliterc == NULL ){
    home_dir = find_home_dir(0);
    if( home_dir==0 ){
      eputz("-- warning: cannot find home directory;"
            " cannot read ~/.sqliterc\n");
      return;







|







12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
  char *home_dir = NULL;
  const char *sqliterc = sqliterc_override;
  char *zBuf = 0;
  FILE *inSaved = p->in;
  int savedLineno = p->lineno;

  if( sqliterc == NULL ){
    sqliterc = zBuf = find_xdg_config();
  }
  if( sqliterc == NULL ){
    home_dir = find_home_dir(0);
    if( home_dir==0 ){
      eputz("-- warning: cannot find home directory;"
            " cannot read ~/.sqliterc\n");
      return;