Improve rc/ scripts

This commit is contained in:
Martin Blazik
2022-05-29 16:15:57 +02:00
parent 61e2fa5a71
commit 91ab592f83
3 changed files with 11 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
# $LWS/rc/functions.sh # $LWS/rc/functions.sh
function xlog() { function xlog() {
if (( $LWS_DEBUG )); then if true_false "$LWS_DEBUG"; then
echo "$@" echo "$@"
fi fi
} }
@@ -33,7 +33,7 @@ function append_path() {
function append_path_try() { function append_path_try() {
if [[ -e "$1" ]]; then if [[ -e "$1" ]]; then
append_pat "$1" append_path "$1"
fi fi
} }
@@ -69,13 +69,17 @@ function can_run() {
function source_directory() { function source_directory() {
local mask="$1" local mask="$1"
for file in $mask; do for file in $mask; do
if [[ -f "$file" ]]; then if [[ -e "$file" ]]; then
xlog "LOAD $file" xlog "LOAD $file"
source "$file" source "$file"
fi fi
done done
} }
function source_directory_sh() {
source_directory "$1/*.sh"
}
# use: dump_args "$@" # use: dump_args "$@"
function dump_args() { function dump_args() {
for i in $*; do for i in $*; do

View File

@@ -1,3 +1,5 @@
alias nop=':'
alias exit-when-error='set -o errexit' alias exit-when-error='set -o errexit'
alias exit-when-unset-variable='set -o nounset' alias exit-when-unset-variable='set -o nounset'
alias exit-when-pipe-fail='set -o pipefail' alias exit-when-pipe-fail='set -o pipefail'

View File

@@ -1,3 +1,4 @@
# Load user locals bashrc # Load user locals bashrc
source_directory "$HOME/.bashrc.d/*.sh" source_directory_sh "$LWS/rc.local"
source_directory_sh "$HOME/.bashrc.d"