Browse Source

Use keyword-less function definition syntax

Alois Mahdal 3 years ago
parent
commit
39c5261d93
1 changed files with 11 additions and 11 deletions
  1. 11
    11
      99bottles.sh

+ 11
- 11
99bottles.sh View File

@@ -8,7 +8,7 @@ wastefulBreakLine="If one of those bottles should happen to fall"
8 8
 breakLine=$([ "$1" = --careless ] && echo $wastefulBreakLine ||
9 9
                                      echo $standardBreakLine)
10 10
 
11
-function pred() {  #get predecessor to a number
11
+pred() {  #get predecessor to a number
12 12
   case $1 in
13 13
     *nine)  echo ${1%nine}eight;;
14 14
     *eight) echo ${1%eight}seven;;
@@ -30,21 +30,21 @@ function pred() {  #get predecessor to a number
30 30
   esac
31 31
   }
32 32
   
33
-function teenpred() { #predecessor of a teen
33
+teenpred() { #predecessor of a teen
34 34
   case $1 in
35 35
      thirteen)   echo twelve;;
36 36
      *)     echo $(crunchprefix $(pred $(uncrunchprefix ${1%teen})))teen;;
37 37
      esac  
38 38
   }
39 39
   
40
-function tenspred() { #predecessor of a multiple of ten
40
+tenspred() { #predecessor of a multiple of ten
41 41
   case $1 in
42 42
      twenty)     echo nineteen;;
43 43
      *) echo $(crunchprefix --tens $(pred $(uncrunchprefix ${1%ty})))ty-nine;;
44 44
      esac  
45 45
   }
46 46
   
47
-function crunchprefix() {
47
+crunchprefix() {
48 48
   #crunch number prefix to its conventional form
49 49
   # such as three --> thir
50 50
   # option --tens     multiples of ten are a bit different
@@ -59,7 +59,7 @@ function crunchprefix() {
59 59
   esac
60 60
   }
61 61
 
62
-function uncrunchprefix() { #reverse crunchprefix
62
+uncrunchprefix() { #reverse crunchprefix
63 63
   case $1 in
64 64
     twen)  echo two;;
65 65
     thir)  echo three;;
@@ -70,7 +70,7 @@ function uncrunchprefix() { #reverse crunchprefix
70 70
   esac
71 71
   }
72 72
     
73
-function grammar() { #peculiarities of English grammar
73
+grammar() { #peculiarities of English grammar
74 74
   local oneBottle=false  #can effect the following line
75 75
   while read line; do
76 76
     line="${line/one more bottles/one more bottle}"
@@ -92,13 +92,13 @@ function grammar() { #peculiarities of English grammar
92 92
     done
93 93
   }
94 94
   
95
-function capitalize() {  #fix beginning of each line
95
+capitalize() {  #fix beginning of each line
96 96
   while read line; do
97 97
     echo -n ${line:0:1} | tr '[:lower:]' '[:upper:]'
98 98
     echo ${line#?}
99 99
     done
100 100
   }
101
-function punctuate() {  #add punct to each line
101
+punctuate() {  #add punct to each line
102 102
   while read line; do 
103 103
     case "${line}" in
104 104
       [Ii]f*)   echo ${line},;;
@@ -108,7 +108,7 @@ function punctuate() {  #add punct to each line
108 108
     done
109 109
   }
110 110
 
111
-function verse () { #write one verse
111
+verse () { #write one verse
112 112
   local nb=$1
113 113
   echo $nb bottles of beer on the wall
114 114
   echo $nb bottles of beer
@@ -122,7 +122,7 @@ function verse () { #write one verse
122 122
   echo $nb bottles of beer on the wall
123 123
   }
124 124
   
125
-function poeticize() { #make it nice
125
+poeticize() { #make it nice
126 126
   while read first rest; do
127 127
     case "$rest" in
128 128
       *beer*)
@@ -137,7 +137,7 @@ function poeticize() { #make it nice
137 137
     done
138 138
   }
139 139
   
140
-function syllables { #estimate number of syls in word
140
+syllables() { #estimate number of syls in word
141 141
   local n=1
142 142
   case $1 in
143 143
     eleven)       n=2;; #sounds better if not considered 3