Browse Source

Factor out code building one file

Increase readability: decrease complexity of the build function and
preserve wandering off too much against 80-char "buoy"
Alois Mahdal 9 years ago
parent
commit
dcfd439485
1 changed files with 17 additions and 9 deletions
  1. 17
    9
      setup/mk.sh

+ 17
- 9
setup/mk.sh View File

32
     exit 9
32
     exit 9
33
 }
33
 }
34
 
34
 
35
+build1() {
36
+    local srcpath dstpath
37
+    srcpath=$1
38
+    dstpath=${srcpath%.in}
39
+    perl -pe "
40
+        s|__FFOO_INIT__|$ffoo_init|;
41
+        s|__FFOO_INI_PATH__|$FFOO_INI_PATH_GLOBAL:\\\$HOME/$FFOO_INI_PATH_USER|;
42
+        s|__VERSION__|$VERSION|;
43
+    " < $srcpath > $dstpath
44
+    echo $dstpath >> built.list
45
+}
46
+
35
 build() {
47
 build() {
36
     ffoom init_path >& /dev/null \
48
     ffoom init_path >& /dev/null \
37
         || die "-----" \
49
         || die "-----" \
40
                "user and repeating the \`make install\` again." \
52
                "user and repeating the \`make install\` again." \
41
                "-----"
53
                "-----"
42
     local ffoo_init=$(ffoom init_path)
54
     local ffoo_init=$(ffoom init_path)
43
-    local srcpath dstpath
55
+    local srcpath
44
     find -type f -name '*.in' \
56
     find -type f -name '*.in' \
45
-        | while read srcpath;
46
-          do
47
-              dstpath=${srcpath%.in}
48
-              perl -pe "s|__FFOO_INIT__|$ffoo_init|;
49
-                        s|__FFOO_INI_PATH__|$FFOO_INI_PATH_GLOBAL:\\\$HOME/$FFOO_INI_PATH_USER|;
50
-                        s|__VERSION__|$VERSION|;" < $srcpath > $dstpath
51
-              echo $dstpath >> built.list
52
-          done
57
+     | while read srcpath;
58
+       do
59
+           build1 "$srcpath"
60
+       done
53
 }
61
 }
54
 
62
 
55
 clean() {
63
 clean() {