Browse Source

Pass $Url to dissect(), in line with Shellfu coding style

Alois Mahdal 6 years ago
parent
commit
a5ada53506
1 changed files with 10 additions and 7 deletions
  1. 10
    7
      bin/dissect_url

+ 10
- 7
bin/dissect_url View File

1
 #!/bin/bash
1
 #!/bin/bash
2
 
2
 
3
 dissect() {
3
 dissect() {
4
-    echo $* | perl -pe '
4
+    #
5
+    # Print "dissected" version of $Url
6
+    #
7
+    echo "$Url" | perl -pe '
5
         s|(\w)(/[^/])|$1\n    $2|;
8
         s|(\w)(/[^/])|$1\n    $2|;
6
         s|\?|\n    ?\n        |;
9
         s|\?|\n    ?\n        |;
7
         s|#|\n    #\n        |;
10
         s|#|\n    #\n        |;
10
 }
13
 }
11
 
14
 
12
 main() {
15
 main() {
13
-    local url=$1
16
+    local Url=$1
14
     local i=0
17
     local i=0
15
-    if [[ -n "$url" ]]; then
16
-        dissect "$url"
18
+    if [[ -n "$Url" ]]; then
19
+        dissect
17
     else
20
     else
18
         i=0
21
         i=0
19
-        while read -r url;
22
+        while read -r Url;
20
         do
23
         do
21
-            if [[ -z "$url" ]]; then exit 0; fi
24
+            if [[ -z "$Url" ]]; then exit 0; fi
22
             ((i++))
25
             ((i++))
23
             printf '=== url %02d =============================================\n' $i
26
             printf '=== url %02d =============================================\n' $i
24
-            dissect "$url"
27
+            dissect
25
         done
28
         done
26
     fi
29
     fi
27
 }
30
 }