Files
config-bash/_helpers.bash
T
xavier 6738296ace fix: Remove dead and broken basedir() from _helpers.bash
basedir() had a broken escape ($(dirname \"$-2\") makes no sense) and
was never called anywhere in the repo — it's a leftover copy of the
already-deprecated libs.deprecated/basedir.bash. bashrc already has
its own get_script_dir() for the same need, with proper symlink
resolution.
2026-08-22 00:55:59 +02:00

39 lines
895 B
Bash

function _source_file_if_exists() {
if [ -r "$1" ]; then
test -n "${DEBUG_BASHRC}" && echo "-- Sourcing file $1"
source "$1"
fi
}
function _source_dir_files() {
if [ -d "$1" ]; then
test -n "${DEBUG_BASHRC}" && echo "-- Sourcing files in directory $1"
# Safe loops for empty dirs
shopt -s nullglob
for file in "$1"/*; do
if [ -e "${file}" ]; then
test -n "${DEBUG_BASHRC}" && echo " * sourcing file ${file}"
source "${file}"
fi
done
# Restore option nullglob to normal
shopt -u nullglob
fi
}
# Source : https://superuser.com/questions/39751/add-directory-to-path-if-its-not-already-there
_path_add() {
if [ -d "$1" ] && [[ ":${PATH}:" != *":$1:"* ]]; then
PATH="${PATH:+"${PATH}:"}$1"
fi
}
_prompt_command_add() {
if [ -n "$1" ] && [[ ":${PROMPT_COMMAND}:" != *":$1:"* ]]; then
PROMPT_COMMAND="${PROMPT_COMMAND:+"${PROMPT_COMMAND};"}$1"
fi
}