diff --git a/bashrc b/bashrc index f02db8d..0e93c08 100644 --- a/bashrc +++ b/bashrc @@ -10,11 +10,9 @@ if [[ -z $LC_ALL ]]; then export LC_ALL=en_US.UTF-8 fi -for rc_file in $WORKSPACE/rc/*.sh; do - source $rc_file -done +source "$LWS/functions.sh" +source_directory_sh "$LWS/rc" append_path "$LWS/bin" append_path "$LWS/opt/bin" set_uniq_path - diff --git a/rc/01-functions.sh b/functions.sh similarity index 87% rename from rc/01-functions.sh rename to functions.sh index 0a38f06..a814179 100644 --- a/rc/01-functions.sh +++ b/functions.sh @@ -1,5 +1,7 @@ # Linux Workspace Functions +readonly time_ms='date +%s%3N' + function xlog() { if true_false "$LWS_DEBUG"; then echo "$@" @@ -84,10 +86,17 @@ function can_run() { function source_directory() { local mask="$1" + xlog "LOAD DIR $mask" for file in $mask; do if [[ -e "$file" ]]; then - xlog "LOAD $file" - source "$file" + if (( $LWS_DEBUG )); then + start=$($time_ms) + source "$file" + stop=$($time_ms) + echo "LOAD FILE $file $((stop - start)) ms" + else + source "$file" + fi fi done } @@ -115,4 +124,3 @@ function true_false() { # [[ "${1,,}" =~ ^(1|true|yes)$ ]] [[ "${1@L}" =~ ^(1|true|yes)$ ]] } -