From 138626991cca00882d47a53b5ab6f8310e0f2ed2 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Thu, 5 Apr 2018 03:20:49 +0100 Subject: [PATCH] etc/profile.d/functions --- etc/profile | 9 +++++---- etc/profile.d/functions | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/etc/profile b/etc/profile index 3c083c25..07a13e44 100755 --- a/etc/profile +++ b/etc/profile @@ -21,7 +21,7 @@ nb_debug() { return 0 } -nb_file_as_tag() { [ "$(head -1 "$1")" = "# " ]; } +_nb_file_has_tag() { [ "$(head -1 "$1")" = "# " ]; } # # Avoid infinit loop. Eg: profile -> .bashrc -> profile @@ -66,7 +66,7 @@ else for i in /*/*/etc/profile.d/nb.sh /*/*/*/etc/profile.d/nb.sh; do cd "$(dirname "$i")"/.. 1>/dev/null 2>&1 || continue - nb_file_as_tag ../profile || continue + _nb_file_has_tag ../profile || continue NB_ETC_DIR=$PWD #|| unset NB_ETC_DIR break @@ -78,6 +78,7 @@ fi _nb_unset() { unset i tmp NB_ETC_DIR NB_DEBUG NB_LOOP + unset -f _nb_file_has_tag 2> /dev/null return 0 } @@ -90,7 +91,7 @@ else #echo "+$NB_ETC_DIR" #echo $NB_ETC_DIR; #return - # Check to avoid system crash ! + # Load source file "functions" and avoid system crash ! nb_debug ". $NB_ETC_DIR/profile.d/functions" if [ ! -e "$NB_ETC_DIR/profile.d/functions" ] || ! . "$NB_ETC_DIR/profile.d/functions"; then echo "ERR: $NB_ETC_DIR: Wrong directory (no profile.d/functions)" 1>&2 @@ -116,7 +117,7 @@ else ; do case "$i" in # no multiple include from other branch - */etc/profile) nb_file_as_tag "$i" && nb_debug "IGNORE $i" && continue ;; + */etc/profile) _nb_file_has_tag "$i" && nb_debug "IGNORE $i" && continue ;; esac nb_debug ". $i" [ -r "$i" -a -f "$i" ] && . "$i" diff --git a/etc/profile.d/functions b/etc/profile.d/functions index 792e8f2e..1e560444 100644 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -825,7 +825,6 @@ _which_cache="" which_cache() { #/usr/bin/which local IFS=':' - local p # Cache case "$_which_cache|" in @@ -840,6 +839,7 @@ which_cache() { esac #nb_debug "which_cache() $1=?" + local p for p in $PATH; do test -x "$p/$1" || continue -- 2.47.3