Replace bare $var with ${var} everywhere it was still used, matching
the convention already established in rc.d/prompt and rc.d/history.
Positional parameters ($1, $@, $#) and special variables ($?, $$, $-)
are left as-is, consistent with existing usage in _helpers.bash.
rc.d/broot is auto-generated by the broot binary and will likely be
overwritten with its original formatting on the next broot update.
43 lines
953 B
Bash
43 lines
953 B
Bash
function basedir() {
|
|
(cd "$(dirname \"$-2\")" && pwd)
|
|
}
|
|
|
|
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
|
|
}
|