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