From ec184df86b5a0c1e4f5c87ef6ae1d0c8ca45ee75 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 9 Jan 2018 18:56:49 +0000 Subject: [PATCH] etc/profile --- etc/profile | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/etc/profile b/etc/profile index d2221e9e..6aa55e80 100755 --- a/etc/profile +++ b/etc/profile @@ -1,4 +1,4 @@ -#-------------------------------------------------------------------------------- +# # # etc/profile # @@ -13,12 +13,15 @@ # #-------------------------------------------------------------------------------- [ "$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")" = "# " ]; } + # # Avoid infinit loop. Eg: profile -> .bashrc -> profile # @@ -62,10 +65,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 - - # 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 @@ -103,14 +103,19 @@ else # # 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 -- 2.47.3