From d5fd7c1bf501bf57ae1a70dfe33780f7706d31c3 Mon Sep 17 00:00:00 2001 From: Terin Stock Date: Wed, 22 May 2024 02:22:56 +0200 Subject: [PATCH] shell: check default XDG_CONFIG_HOME dir The XDG documentation states the default of `$HOME/.config` should be used when `$XDG_CONFIG_HOME` is unset or empty. This changeset modifies the shell startup to query this location if the environment variable is not being set to another value. --- src/shell.c.in | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/shell.c.in b/src/shell.c.in index 1220b42..3c2c8ce 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -11795,6 +11795,7 @@ static const char *find_xdg_config(void){ static int alreadyTried = 0; static char *zConfig = 0; const char *zXdgHome; + char *home_dir = NULL; if( alreadyTried!=0 ){ return zConfig; @@ -11803,6 +11804,16 @@ static const char *find_xdg_config(void){ zXdgHome = getenv("XDG_CONFIG_HOME"); if( zXdgHome==0 ){ - return 0; + home_dir = find_home_dir(0); + if( home_dir != 0 ) { + zConfig = sqlite3_mprintf("%s/.config/sqlite3/sqliterc", home_dir); + shell_check_oom(zConfig); + if( access(zConfig,0)!=0 ){ + sqlite3_free(zConfig); + zConfig = 0; + } else { + return zConfig; + } + } } zConfig = sqlite3_mprintf("%s/sqlite3/sqliterc", zXdgHome); shell_check_oom(zConfig); -- 2.44.1