-#--------------------------------------------------------------------------------
+# <NB_TAG>
#
# etc/profile
#
#
#--------------------------------------------------------------------------------
[ "$1" = "--nb-debug" ] && export NB_DEBUG="yes" && shift
+[ "$1" = "--nb-no-repos" ] && export NB_NO_REPOS="yes" && shift
nb_debug() {
[ -n "$NB_DEBUG" -a "$NB_DEBUG" = "yes" ] || return 0
echo "DEBUG: $*" 1>&2
return 0
}
+nb_file_as_tag() { [ "$(head -1 "$1")" = "# <NB_TAG>" ]; }
+
#
# Avoid infinit loop. Eg: profile -> .bashrc -> profile
#
for i in /*/*/etc/profile.d/nb.sh /*/*/*/etc/profile.d/nb.sh; do
cd "$(dirname "$i")"/.. 1>/dev/null 2>&1 || continue
-
- # Check other files
- [ -e profile.d/envs ] || continue
- [ -e profile.d/aliases ] || continue
+ nb_file_as_tag ../profile || continue
NB_ETC_DIR=$PWD #|| unset NB_ETC_DIR
break
#
# Profiles
#
+# NB 09.01.18 $(true || nb_repos_ls "etc/profile" "etc/profile.d/*.sh" | awk '!/^\/etc\// && $0 != "'${NB_ROOT}/etc/profile'"') \
if [ -n "$NB_ROOT" ]; then
alias which=which_cache
for i in \
${NB_ROOT}/etc/profile.d/envs \
${NB_ROOT}/etc/profile.d/aliases \
- $(nb_repos_ls "etc/profile" "etc/profile.d/*.sh" | awk '!/^\/etc\// && $0 != "'${NB_ROOT}/etc/profile'"') \
+ ${NB_ROOT}/etc/profile.d/*.sh \
+ $([ "$NB_NO_REPOS" = "yes" ] || nb_repos_ls "etc/profile" "etc/profile.d/*.sh" | grep -v "^$NB_ROOT/") \
; do
+ case "$i" in
+ */etc/profile) nb_file_as_tag "$i" && nb_debug "IGNORE $i" && continue
+ esac
nb_debug ". $i"
[ -r "$i" -a -f "$i" ] && . "$i"
done