drop `dirname` in favor of native Bash strings (1 of 2)

Convert `var=${dirname $filename)` to `var="${filename%/*}` in cases where there is no ambiguity.

Make sure that the path in `$BASH_IT` is absolute because this path gets embedded in the template `.bash_profile` file if selected by the user.
pull/1926/head
John D Pell 2021-09-11 23:45:34 -07:00
parent f9de8d170a
commit dee55a03cc
3 changed files with 6 additions and 6 deletions

View File

@ -184,7 +184,7 @@ if [[ $no_modify_config ]] && [[ $append_to_config ]]; then
exit 1 exit 1
fi fi
BASH_IT="$(cd "$(dirname "$0")" && pwd)" BASH_IT="$(cd "${BASH_SOURCE%/*}" && pwd)"
case $OSTYPE in case $OSTYPE in
darwin*) darwin*)

View File

@ -71,12 +71,12 @@ _bash-it-grep() {
########################################################################### ###########################################################################
_bash-it-component-help() { _bash-it-component-help() {
local component=$(_bash-it-pluralize-component "${1}") local component="$(_bash-it-pluralize-component "${1}")"
local file=$(_bash-it-component-cache-file ${component}) local file="$(_bash-it-component-cache-file "${component}")"
if [[ ! -s "${file}" || -z $(find "${file}" -mmin -300) ]] ; then if [[ ! -s "${file}" || -z $(find "${file}" -mmin -300) ]] ; then
rm -f "${file}" 2>/dev/null rm -f "${file}" 2>/dev/null
local func="_bash-it-${component}" local func="_bash-it-${component}"
${func} | $(_bash-it-grep) -E ' \[' | cat > ${file} "${func}" | $(_bash-it-grep) -E ' \[' | cat > "${file}"
fi fi
cat "${file}" cat "${file}"
} }
@ -84,7 +84,7 @@ _bash-it-component-help() {
_bash-it-component-cache-file() { _bash-it-component-cache-file() {
local component=$(_bash-it-pluralize-component "${1}") local component=$(_bash-it-pluralize-component "${1}")
local file="${BASH_IT}/tmp/cache/${component}" local file="${BASH_IT}/tmp/cache/${component}"
[[ -f ${file} ]] || mkdir -p $(dirname ${file}) [[ -f "${file}" ]] || mkdir -p "${file%/*}"
printf "${file}" printf "${file}"
} }

View File

@ -11,7 +11,7 @@ autoenv_init()
typeset target home _file typeset target home _file
typeset -a _files typeset -a _files
target=$1 target=$1
home="$(dirname "$HOME")" home="${HOME%/*}"
_files=( $( _files=( $(
while [[ "$PWD" != "/" && "$PWD" != "$home" ]] while [[ "$PWD" != "/" && "$PWD" != "$home" ]]