Browse Source

Simplify control flow ("return is the best if")

Alois Mahdal 6 years ago
parent
commit
73f7b9178a
1 changed files with 8 additions and 9 deletions
  1. 8
    9
      bin/dissect_url

+ 8
- 9
bin/dissect_url View File

@@ -15,16 +15,15 @@ dissect() {
15 15
 main() {
16 16
     local Url=$1
17 17
     local i=0
18
-    if [[ -n "$Url" ]]; then
18
+    test -n "$Url" \
19
+     && dissect \
20
+     && return 0
21
+    while read -r Url;
22
+    do
23
+        ((i++))
24
+        printf '=== url %02d =============================================\n' $i
19 25
         dissect
20
-    else
21
-        while read -r Url;
22
-        do
23
-            ((i++))
24
-            printf '=== url %02d =============================================\n' $i
25
-            dissect
26
-        done
27
-    fi
26
+    done
28 27
 }
29 28
 
30 29
 main "$@"