lib/utilities: XDG_CACHE_HOME

Use $XDG_CACHE_HOME environment constant instead of placing a tmp/cache folder inside the bash-it data repo. If not defined, fall back to current behavior.

This resolves Bash-It/Bash-It#1904.
pull/1973/head
John D Pell 2021-10-12 13:16:28 -07:00
parent 7cd02781f8
commit b986c39040
1 changed files with 2 additions and 2 deletions

View File

@ -83,8 +83,8 @@ function _bash-it-component-help() {
function _bash-it-component-cache-file() { function _bash-it-component-cache-file() {
local component file local component file
component="$(_bash-it-pluralize-component "${1}")" component="$(_bash-it-pluralize-component "${1?${FUNCNAME[0]}: component name required}")"
file="${BASH_IT?}/tmp/cache/${component}" file="${XDG_CACHE_HOME:-${BASH_IT?}/tmp/cache}${XDG_CACHE_HOME:+/bash_it}/${component}"
[[ -f "${file}" ]] || mkdir -p "${file%/*}" [[ -f "${file}" ]] || mkdir -p "${file%/*}"
printf '%s' "${file}" printf '%s' "${file}"
} }