]> git.nbdom.net Git - nb.git/commitdiff
etc/profile
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 9 Jan 2018 18:56:49 +0000 (18:56 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 9 Jan 2018 18:56:49 +0000 (18:56 +0000)
etc/profile

index d2221e9e2c10a19a37490a4d31a4d6e92311c5aa..6aa55e803d2993117640e31963e5849947901f76 100755 (executable)
@@ -1,4 +1,4 @@
-#--------------------------------------------------------------------------------
+# <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
 #
@@ -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