Browse Source

zephyr-env.sh: Use $XDG_CONFIG_HOME/zephry/zephyrrc if present

According to the [XDG Base Directory Specification] there is a single base
directory in which user configuration files should be stored. This helps
users to keep their home directory uncluttered. This base directory can be
set in the environment variable $XDG_CONFIG_HOME and defaults to
${HOME}/.config if $XDG_CONFIG_HOME is not set.

This commit adjusts the zephyr-env.sh script to look for a user
configuration file in the following locations:

- $XDG_CONFIG_HOME/zephyr/zephyrrc
- $HOME/.config/zephyr/zephyrrc
- $HOME/.zephyrrc

The first one that is found will be used.

[XDG Base Directory Specification]: (https://specifications.freedesktop.org/basedir-spec/latest/)

Signed-off-by: Andreas Schuster <andreas.schuster@schuam.de>
pull/92038/merge
Andreas Schuster 3 months ago committed by Dan Kalowsky
parent
commit
0f0497f9c5
  1. 14
      zephyr-env.sh

14
zephyr-env.sh

@ -64,6 +64,14 @@ zephyr_answer_file=~/zephyr-env_install.bash
. ${zephyr_answer_file} . ${zephyr_answer_file}
} }
unset zephyr_answer_file unset zephyr_answer_file
zephyr_answer_file=~/.zephyrrc xdg_config_home="${XDG_CONFIG_HOME:-${HOME}/.config}"
[ -f ${zephyr_answer_file} ] && . ${zephyr_answer_file} zephyr_xdg_rc="${xdg_config_home}/zephyr/zephyrrc"
unset zephyr_answer_file if [ -f "${zephyr_xdg_rc}" ]; then
. "${zephyr_xdg_rc}"
else
zephyr_answer_file=~/.zephyrrc
[ -f "${zephyr_answer_file}" ] && . "${zephyr_answer_file}"
unset zephyr_answer_file
fi
unset zephyr_xdg_rc
unset xdg_config_home

Loading…
Cancel
Save