]> Frank Brehm's Git Trees - config/bruni/etc.git/commitdiff
saving uncommitted changes in /etc prior to emerge run
authorFrank Brehm <frank@brehm-online.com>
Sun, 8 Apr 2018 10:55:05 +0000 (12:55 +0200)
committerFrank Brehm <root@bruni.home.brehm-online.com>
Sun, 8 Apr 2018 10:55:05 +0000 (12:55 +0200)
slsh.rc

diff --git a/slsh.rc b/slsh.rc
index e8043d9acdd34bf5af4651d68f912d15b4a2da43..7485c13703d8fee20d094fd0fbca8beecbc3a395 100644 (file)
--- a/slsh.rc
+++ b/slsh.rc
@@ -5,11 +5,29 @@
 
 private define dir_exists (dir)
 {
+   if (dir == NULL) return 0;
    variable s = stat_file (dir);
    if (s == NULL) return 0;
    return stat_is ("dir", s.st_mode);
 }
 
+private define check_dirs (dirs)
+{
+   if (dirs == NULL)
+     return NULL;
+
+   variable new_dirs = String_Type[0];
+   foreach (strchop (dirs, path_get_delimiter(), 0))
+     {
+       variable dir = ();
+       if (dir_exists (dir))
+         new_dirs = [new_dirs, dir];
+     }
+   if (length (new_dirs) == 0)
+     return NULL;
+   return strjoin (new_dirs, char (path_get_delimiter()));
+}
+
 %!%+
 %\function{prepend_to_slang_load_path}
 %\synopsis{Prepend a directory to the load-path}
@@ -21,7 +39,8 @@ private define dir_exists (dir)
 %!%-
 public define prepend_to_slang_load_path (p)
 {
-   if (dir_exists (p))
+   p = check_dirs (p);
+   if (p != NULL)
      set_slang_load_path (sprintf ("%s%c%s", p, path_get_delimiter (), get_slang_load_path ()));
 }
 
@@ -36,15 +55,20 @@ public define prepend_to_slang_load_path (p)
 %!%-
 public define append_to_slang_load_path (p)
 {
-   if (dir_exists (p))
+   p = check_dirs (p);
+   if (p != NULL)
      set_slang_load_path (sprintf ("%s%c%s", get_slang_load_path (), path_get_delimiter (), p));
 }
 
-() = evalfile ("autoload.sl");
-
+% This function gets called from slsh after loading this file
+public define __slsh_startup_hook ()
+{
+   () = evalfile ("autoload.sl");
 #ifdef __INTERACTIVE__
-() = evalfile ("slshrl.sl");
+   () = evalfile ("slshrl.sl");
 #endif
+}
+prepend_to_slang_load_path (getenv (SLSH_PATH_ENV));
 
 % Add local additions here