Selaa lähdekoodia

Use more compact `do`/`then` form

Drop the unnecessary and space-wasting requirement that `do` and `then`
must be alone on line.  It's a thing of the past!
Alois Mahdal 7 vuotta sitten
vanhempi
commit
b44e804804
6 muutettua tiedostoa jossa 24 lisäystä ja 47 poistoa
  1. 6
    12
      src/include/build.sh
  2. 6
    12
      src/include/deploy.sh
  3. 1
    2
      src/include/facts.sh
  4. 8
    15
      src/include/ini.sh
  5. 2
    4
      src/include/mkit.sh
  6. 1
    2
      src/include/release.sh

+ 6
- 12
src/include/build.sh Näytä tiedosto

@@ -68,12 +68,10 @@ _expand_tokens() {
68 68
     local varvalue      # each token value
69 69
     script=$(mktemp --tmpdir mkit-tmp.XXXXXXXXXX)
70 70
     {
71
-        for section in "$@";
72
-        do
71
+        for section in "$@"; do
73 72
             debug_var section
74 73
             ini lskeys "$section" \
75
-              | while read -r varname;
76
-                do
74
+              | while read -r varname; do
77 75
                     varvalue="$(ini 1value "$section:$varname" | _qfs )"
78 76
                     echo "s|$varname|$varvalue|g;"
79 77
                     debug_var varname varvalue
@@ -120,8 +118,7 @@ build() {
120 118
     #
121 119
     local srcpath   # each source path
122 120
     find -type f -name '*.skel' \
123
-     | while read -r srcpath;
124
-       do
121
+     | while read -r srcpath; do
125 122
            _build1 "$srcpath"
126 123
        done
127 124
 }
@@ -132,11 +129,9 @@ build_manpages() {
132 129
     #
133 130
     local manfile   # each manual file listed in '[files:man]'
134 131
     local mdfile    # each source markdown file
135
-    if command -v ronn >/dev/null;
136
-    then
132
+    if command -v ronn >/dev/null; then
137 133
         ini lskeys "files:man" \
138
-          | while read -r manfile;
139
-            do
134
+          | while read -r manfile; do
140 135
                 mdfile="$manfile.md"
141 136
                 ronn -r "$mdfile"
142 137
                 mkdir -p "$MKIT_LOCAL"
@@ -185,8 +180,7 @@ debstuff() {
185 180
     test -d "$debian_skel" || die "debian directory template found: $debian_skel"
186 181
     mkdir -p debian/source
187 182
     find "$debian_skel" -type f \
188
-      | while read -r dfsrc;
189
-        do
183
+      | while read -r dfsrc; do
190 184
             dftgt="debian/${dfsrc#$debian_skel}"
191 185
             mkdir -p "$(dirname "$dftgt")"
192 186
             _build1 "$dfsrc" "$dftgt" debstuff

+ 6
- 12
src/include/deploy.sh Näytä tiedosto

@@ -27,13 +27,11 @@ _deploy_item() {
27 27
     local dst=$2                            # destination path
28 28
     local mode=${3:-$MKIT_DEFAULT_MODE}     # mode
29 29
     local chmod_item                        # each file to chmod in directory
30
-    if test -d "$src";
31
-    then
30
+    if test -d "$src"; then
32 31
         _maybe mkdir -vp "$(dirname "$dst")"
33 32
         _maybe cp -Tvr "$src" "$dst"
34 33
         find "$dst" -type f \
35
-          | while read -r chmod_item;
36
-            do
34
+          | while read -r chmod_item; do
37 35
                 _maybe chmod "$mode" "$chmod_item"
38 36
             done
39 37
     else
@@ -94,12 +92,10 @@ install() {
94 92
     ini lskeys "files" \
95 93
       | sort \
96 94
       | uniq \
97
-      | while read -r group;
98
-        do
95
+      | while read -r group; do
99 96
             mode=$(ini 1value "modes:$group")
100 97
             ini values "files:$group" \
101
-              | while read -r src dst;
102
-                do
98
+              | while read -r src dst; do
103 99
                     dst=$(_get_dst "$group" "$src" "$dst")
104 100
                     _deploy_item "$src" "$dst" "$mode"
105 101
                 done
@@ -118,11 +114,9 @@ uninstall() {
118 114
     ini lskeys "files" \
119 115
       | sort \
120 116
       | uniq \
121
-      | while read -r group;
122
-        do
117
+      | while read -r group; do
123 118
             ini values "files:$group" \
124
-              | while read -r src dst;
125
-                do
119
+              | while read -r src dst; do
126 120
                     dst=$(_get_dst "$group" "$src" "$dst")
127 121
                     _maybe rm -vrf "$dst"
128 122
                 done

+ 1
- 2
src/include/facts.sh Näytä tiedosto

@@ -89,8 +89,7 @@ git_lasthash() {
89 89
     # target, but that's actually expected.)
90 90
     #
91 91
     local last_hash     # last commit hash
92
-    if git_present;
93
-    then    # we are in git repo
92
+    if git_present; then    # we are in git repo
94 93
         last_hash=$(git rev-parse HEAD)
95 94
         echo -n "$last_hash"
96 95
         git_bool dirty && echo -n ".dirty"

+ 8
- 15
src/include/ini.sh Näytä tiedosto

@@ -5,8 +5,7 @@ _ini_cat() {
5 5
     # A no-op for text stream
6 6
     #
7 7
     local line      # each line
8
-    while read -r line;
9
-    do
8
+    while read -r line; do
10 9
         printf -- "%s\n" "$line"
11 10
     done
12 11
 }
@@ -19,8 +18,7 @@ _ini_expand() {
19 18
     local suffix    # tail of the line
20 19
     local ref       # reference
21 20
     local value     # value if reference
22
-    while read -r line;                     # [foo:bar]/path
23
-    do
21
+    while read -r line; do                  # [foo:bar]/path
24 22
         suffix="${line#\[*\]}"              # /path
25 23
         ref="${line%$suffix}"               # [foo:bar]
26 24
         ref="${ref%\]}"                     # [foo:bar
@@ -56,14 +54,11 @@ _ini_greppath() {
56 54
     local wntkey=${wnt##*:}         # ^^ key part
57 55
     local wntsec=${wnt%:$wntkey}    # ^^ section part
58 56
     local override                  # ENV override (only ENV section)
59
-    if test "$wntsec" = 'ENV';
60
-    then
57
+    if test "$wntsec" = 'ENV'; then
61 58
         override=${!wntkey}
62
-        if test -n "$override";
63
-        then
64
-            echo "$override"
65
-            return
66
-        fi
59
+        test -n "$override" \
60
+         && echo "$override" \
61
+         && return
67 62
     fi
68 63
     _ini_grepsec "$wntsec" | _ini_grepkey "$wntkey"
69 64
 }
@@ -77,8 +72,7 @@ _ini_grepsec() {
77 72
     local line          # each input line
78 73
     grep '.' \
79 74
       | grep -v '\s*#' \
80
-      | while read -r line;
81
-        do
75
+      | while read -r line; do
82 76
             case "$line" in
83 77
                 \[$wnt\]) ok=true;  continue ;;
84 78
                 \[*\])    ok=false; continue ;;
@@ -101,8 +95,7 @@ _ini_maybe_expand() {
101 95
     #
102 96
     # Decide whether or not to expand
103 97
     #
104
-    if test "$MKIT_INI_EXPAND" -gt 0;
105
-    then
98
+    if test "$MKIT_INI_EXPAND" -gt 0; then
106 99
         MKIT_INI_EXPAND=$(( --MKIT_INI_EXPAND )) _ini_expand
107 100
     else
108 101
         _ini_cat

+ 2
- 4
src/include/mkit.sh Näytä tiedosto

@@ -39,8 +39,7 @@ debug_var() {
39 39
     #
40 40
     $MKIT_DEBUG || return 0
41 41
     local __mkit_debug_var_name__       # variable name to debug
42
-    for __mkit_debug_var_name__ in "$@";
43
-    do
42
+    for __mkit_debug_var_name__ in "$@"; do
44 43
         {
45 44
             echo -n "MKIT_DEBUG: ${FUNCNAME[1]}():"
46 45
             echo -n " $__mkit_debug_var_name__"
@@ -125,8 +124,7 @@ route() {
125 124
     #
126 125
     # Call correct function based on $1
127 126
     #
128
-    if _valid_targets | grep -qwx "^$1";
129
-    then
127
+    if _valid_targets | grep -qwx "^$1"; then
130 128
         "$1"
131 129
     else
132 130
         {

+ 1
- 2
src/include/release.sh Näytä tiedosto

@@ -107,8 +107,7 @@ _release() {
107 107
 
108 108
     reldst=$(ini 1value project:reldst)
109 109
     debug_var reldst
110
-    if test -n "$reldst";
111
-    then
110
+    if test -n "$reldst"; then
112 111
         git branch -f "$reldst" "$newtag"
113 112
     fi
114 113
 }