You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
1.4 KiB

  1. % -*- slang -*-
  2. % This file gets loaded whenever slsh runs. Its primary purpose is to define
  3. % some functions that are useful in scripts, and to set up some local paths
  4. private define dir_exists (dir)
  5. {
  6. variable s = stat_file (dir);
  7. if (s == NULL) return 0;
  8. return stat_is ("dir", s.st_mode);
  9. }
  10. %!%+
  11. %\function{prepend_to_slang_load_path}
  12. %\synopsis{Prepend a directory to the load-path}
  13. %\usage{prepend_to_slang_load_path (String_Type dir)}
  14. %\description
  15. % This function adds a directory to the beginning of the interpreter's
  16. % load-path.
  17. %\seealso{append_to_slang_load_path, set_slang_load_path}
  18. %!%-
  19. public define prepend_to_slang_load_path (p)
  20. {
  21. if (dir_exists (p))
  22. set_slang_load_path (sprintf ("%s%c%s", p, path_get_delimiter (), get_slang_load_path ()));
  23. }
  24. %!%+
  25. %\function{append_to_slang_load_path}
  26. %\synopsis{Append a directory to the load-path}
  27. %\usage{append_to_slang_load_path (String_Type dir)}
  28. %\description
  29. % This function adds a directory to the end of the interpreter's
  30. % load-path.
  31. %\seealso{prepend_to_slang_load_path, set_slang_load_path}
  32. %!%-
  33. public define append_to_slang_load_path (p)
  34. {
  35. if (dir_exists (p))
  36. set_slang_load_path (sprintf ("%s%c%s", get_slang_load_path (), path_get_delimiter (), p));
  37. }
  38. () = evalfile ("autoload.sl");
  39. #ifdef __INTERACTIVE__
  40. () = evalfile ("slshrl.sl");
  41. #endif
  42. % Add local additions here
  43. prepend_to_slang_load_path("/usr/share/slsh/local-packages");