From 754df23b97e6720c3f773f1a6e783154a9b2a22b Mon Sep 17 00:00:00 2001 From: sev Date: Fri, 20 Oct 2023 14:26:06 -0500 Subject: [PATCH] zshenv: fix xdg array logic $xdg_*_dirs parameter expansion was augmented to use :# to remove empty elements, to replace the old system that used the scalar $XDG_*_DIRS parameters. the old code was originally added to remove the first value of the DIRS arrays if they were empty. however, the $XDG_*_HOME vars were unquoted a while ago, and zsh should already remove empty elements from unquoted array expansions, rendering that safeguard unnecessary. the newest change also introduced a regression where the arrays were being flattened into scalars. this also caused KDE to not start due to being unable to find necessary system files elided by the broken vars. this was all fixed by removing the empty var removal code, and simply unquoting everything. since SH_WORDSPLIT is not set, the parameters will not be wordsplit. this also fixed an issue where duplicate array values were not being removed due to the presence of a trailing slash. --- etc/zsh/.zshenv | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/etc/zsh/.zshenv b/etc/zsh/.zshenv index f961cfb..e20553d 100644 --- a/etc/zsh/.zshenv +++ b/etc/zsh/.zshenv @@ -214,8 +214,7 @@ if [[ ! -v _sev_setup_xdg ]] { mkdir -m760 ~/.local/share } xdg_data_dirs=($XDG_DATA_HOME /{opt,usr/local,usr/pkg,usr}/share - ${XDG_DATA_DIRS:+"$xdg_data_dirs[@]"}) - xdg_data_dirs=${xdg_data_dirs:#} + ${XDG_DATA_DIRS:+${xdg_data_dirs%%/}}) export XDG_DATA_DIRS typeset -UT XDG_CONFIG_DIRS xdg_config_dirs @@ -226,9 +225,9 @@ if [[ ! -v _sev_setup_xdg ]] { } # I am of the belief .local should follow FHS /usr/local... [[ -e ~/.local/etc ]] || ln -s ~/.config ~/.local/etc - xdg_config_dirs=($XDG_CONFIG_HOME ${XDG_CONFIG_DIRS:+"$xdg_config_dirs[@]"} + xdg_config_dirs=($XDG_CONFIG_HOME + ${XDG_CONFIG_DIRS:+${xdg_config_dirs%%/}} {/opt,/usr/local,/usr/pkg,}/etc/xdg) - xdg_config_dirs=${xdg_config_dirs:#} export XDG_CONFIG_DIRS if [[ -v XDG_STATE_HOME ]] { -- 2.47.0