Browse Source

Use inigrep__mkpath to assemble FFOO_INIGREP_PATH

Minimize the "built part" and code repetition among saturnin "clones".
Alois Mahdal 9 years ago
parent
commit
c80c7d4a00
1 changed files with 13 additions and 41 deletions
  1. 13
    41
      src/bin/saturnin.skel

+ 13
- 41
src/bin/saturnin.skel View File

@@ -2,49 +2,22 @@
2 2
 
3 3
 . $(ffoom path) || exit 3
4 4
 
5
+ffoo import exit
6
+ffoo import inigrep
7
+ffoo import pretty
8
+
5 9
 #
6 10
 # =====BEGIN BUILT PART=====
7 11
 #
8 12
 
9
-inigrep_modules() {
10
-    #
11
-    # Find existing modules (ini.d sub-folders)
12
-    #
13
-    test -d "$1" || return 0
14
-    find -L "$1" -mindepth 1 -maxdepth 1 -type d \
15
-      | LC_ALL=C sort
16
-}
17
-
18
-inigrep_mkpath() {
19
-    #
20
-    # Assemble list of config paths for FFOO_INIGREP_PATH (path per line)
21
-    #
22
-    local userd     # user'd modular config (~/.xyz/ini.d)
23
-    local user      # user's generic config
24
-    local lcal      # local admin provided config
25
-    local distd     # distribution-provided config (always modular)
26
-    local path      # one path item
27
-    userd="__SATURNIN_CONFIG_USER__/ini.d"
28
-    user="__SATURNIN_CONFIG_USER__"
29
-    lcal="__SATURNIN_CONFIG_LOCAL__"
30
-    distd="__SATURNIN_SHARE__/ini.d"
31
-    {
32
-        inigrep_modules "$userd"
33
-        echo "$user"
34
-        echo "$lcal"
35
-        inigrep_modules "$distd"
36
-    } \
37
-      | while read path;
38
-        do
39
-            test -z "$path" && continue
40
-            echo -n "$path:"
41
-        done
42
-}
13
+FFOO_INIGREP_PATH="$(
14
+    inigrep__mkpath \
15
+        __SATURNIN_CONFIG_USER__/ini.d \
16
+        __SATURNIN_CONFIG_USER__ \
17
+        __SATURNIN_CONFIG_LOCAL__ \
18
+        __SATURNIN_SHARE__/ini.d
19
+)"
43 20
 
44
-export FFOO_INIGREP_PATH FFOO_PATH FFOO_PRETTY_USAGE \
45
-       SATURNIN_VERSION SATURNIN_CACHE_HOME
46
-
47
-FFOO_INIGREP_PATH="$(inigrep_mkpath)"
48 21
 FFOO_PATH="__SATURNIN_FFOO_DIR__"
49 22
 FFOO_PRETTY_USAGE="subcommand"
50 23
 SATURNIN_CACHE_HOME="__SATURNIN_CACHE_HOME__"
@@ -55,9 +28,8 @@ SATURNIN_VERSION="__VERSION__"
55 28
 # =====END BUILT PART=====
56 29
 #
57 30
 
58
-ffoo import exit
59
-ffoo import inigrep
60
-ffoo import pretty
31
+export FFOO_INIGREP_PATH FFOO_PATH FFOO_PRETTY_USAGE \
32
+       SATURNIN_VERSION SATURNIN_CACHE_HOME
61 33
 
62 34
 usage() {
63 35
     mkusage "[-d|-v] command [args...]" \