|  | @@ -22,22 +22,22 @@ pred() {
 | 
	
		
			
			| 22 | 22 |      #
 | 
	
		
			
			| 23 | 23 |      local numeral=$1    # number in word form
 | 
	
		
			
			| 24 | 24 |      case $numeral in
 | 
	
		
			
			| 25 |  | -        *nine)      echo ${numeral%nine}eight;;
 | 
	
		
			
			| 26 |  | -        *eight)     echo ${numeral%eight}seven;;
 | 
	
		
			
			| 27 |  | -        *seven)     echo ${numeral%seven}six;;
 | 
	
		
			
			| 28 |  | -        *six)       echo ${numeral%six}five;;
 | 
	
		
			
			| 29 |  | -        *five)      echo ${numeral%five}four;;
 | 
	
		
			
			| 30 |  | -        *four)      echo ${numeral%four}three;;
 | 
	
		
			
			| 31 |  | -        *three)     echo ${numeral%three}two;;
 | 
	
		
			
			| 32 |  | -        *two)       echo ${numeral%two}one;;
 | 
	
		
			
			| 33 |  | -        one)        echo zero;;
 | 
	
		
			
			| 34 |  | -        *-one)      echo ${numeral%-one};;
 | 
	
		
			
			| 35 |  | -        *one)       echo ${numeral%one};;
 | 
	
		
			
			| 36 |  | -        ten)        echo nine;;
 | 
	
		
			
			| 37 |  | -        eleven)     echo ten;;
 | 
	
		
			
			| 38 |  | -        twelve)     echo eleven;;
 | 
	
		
			
			| 39 |  | -        *teen)      teenpred $numeral;;
 | 
	
		
			
			| 40 |  | -        *ty)        tenspred $numeral;;
 | 
	
		
			
			|  | 25 | +        *nine)      echo "${numeral%nine}eight" ;;
 | 
	
		
			
			|  | 26 | +        *eight)     echo "${numeral%eight}seven" ;;
 | 
	
		
			
			|  | 27 | +        *seven)     echo "${numeral%seven}six" ;;
 | 
	
		
			
			|  | 28 | +        *six)       echo "${numeral%six}five" ;;
 | 
	
		
			
			|  | 29 | +        *five)      echo "${numeral%five}four" ;;
 | 
	
		
			
			|  | 30 | +        *four)      echo "${numeral%four}three" ;;
 | 
	
		
			
			|  | 31 | +        *three)     echo "${numeral%three}two" ;;
 | 
	
		
			
			|  | 32 | +        *two)       echo "${numeral%two}one" ;;
 | 
	
		
			
			|  | 33 | +        one)        echo "zero" ;;
 | 
	
		
			
			|  | 34 | +        *-one)      echo "${numeral%-one}" ;;
 | 
	
		
			
			|  | 35 | +        *one)       echo "${numeral%one}" ;;
 | 
	
		
			
			|  | 36 | +        ten)        echo "nine" ;;
 | 
	
		
			
			|  | 37 | +        eleven)     echo "ten" ;;
 | 
	
		
			
			|  | 38 | +        twelve)     echo "eleven" ;;
 | 
	
		
			
			|  | 39 | +        *teen)      teenpred "$numeral" ;;
 | 
	
		
			
			|  | 40 | +        *ty)        tenspred "$numeral" ;;
 | 
	
		
			
			| 41 | 41 |          zero)       echo "";  #to terminate
 | 
	
		
			
			| 42 | 42 |      esac
 | 
	
		
			
			| 43 | 43 |  }
 | 
	
	
		
			
			|  | @@ -49,7 +49,7 @@ teenpred() {
 | 
	
		
			
			| 49 | 49 |      local numeral=$1    # number in word form
 | 
	
		
			
			| 50 | 50 |      case $numeral in
 | 
	
		
			
			| 51 | 51 |          thirteen)   echo twelve;;
 | 
	
		
			
			| 52 |  | -        *)          echo $(crunchprefix $(pred $(uncrunchprefix ${numeral%teen})))teen;;
 | 
	
		
			
			|  | 52 | +        *)          echo "$(crunchprefix "$(pred "$(uncrunchprefix "${numeral%teen}")")")teen" ;;
 | 
	
		
			
			| 53 | 53 |      esac
 | 
	
		
			
			| 54 | 54 |  }
 | 
	
		
			
			| 55 | 55 |  
 | 
	
	
		
			
			|  | @@ -60,7 +60,7 @@ tenspred() {
 | 
	
		
			
			| 60 | 60 |      local numeral=$1    # number in word form
 | 
	
		
			
			| 61 | 61 |      case $numeral in
 | 
	
		
			
			| 62 | 62 |          twenty)     echo nineteen;;
 | 
	
		
			
			| 63 |  | -        *) echo $(crunchprefix --tens $(pred $(uncrunchprefix ${numeral%ty})))ty-nine;;
 | 
	
		
			
			|  | 63 | +        *) echo "$(crunchprefix --tens "$(pred "$(uncrunchprefix "${numeral%ty}")")")ty-nine";;
 | 
	
		
			
			| 64 | 64 |      esac
 | 
	
		
			
			| 65 | 65 |  }
 | 
	
		
			
			| 66 | 66 |  
 | 
	
	
		
			
			|  | @@ -74,15 +74,15 @@ crunchprefix() {
 | 
	
		
			
			| 74 | 74 |      #
 | 
	
		
			
			| 75 | 75 |      local numeral       # number in word form
 | 
	
		
			
			| 76 | 76 |      local tensop        # 'true' if --tens option is active
 | 
	
		
			
			| 77 |  | -    [ $1 = --tens ] && { tensop=true; shift; }
 | 
	
		
			
			|  | 77 | +    [ "$1" = --tens ] && { tensop=true; shift; }
 | 
	
		
			
			| 78 | 78 |      numeral=$1
 | 
	
		
			
			| 79 | 79 |      case $numeral in
 | 
	
		
			
			| 80 |  | -        two)    [ -n "$tensop" ] && echo twen || echo $numeral;;
 | 
	
		
			
			|  | 80 | +        two)    [ -n "$tensop" ] && echo twen || echo "$numeral";;
 | 
	
		
			
			| 81 | 81 |          three)  echo thir;;
 | 
	
		
			
			| 82 |  | -        four)   [ -n "$tensop" ] && echo 'for' || echo $numeral;;
 | 
	
		
			
			|  | 82 | +        four)   [ -n "$tensop" ] && echo 'for' || echo "$numeral";;
 | 
	
		
			
			| 83 | 83 |          five)   echo fif;;
 | 
	
		
			
			| 84 |  | -        eight)  [ -n "$tensop" ] && echo eigh || echo $numeral;;
 | 
	
		
			
			| 85 |  | -        *)      echo $numeral;;
 | 
	
		
			
			|  | 84 | +        eight)  [ -n "$tensop" ] && echo eigh || echo "$numeral";;
 | 
	
		
			
			|  | 85 | +        *)      echo "$numeral" ;;
 | 
	
		
			
			| 86 | 86 |      esac
 | 
	
		
			
			| 87 | 87 |  }
 | 
	
		
			
			| 88 | 88 |  
 | 
	
	
		
			
			|  | @@ -97,7 +97,7 @@ uncrunchprefix() {
 | 
	
		
			
			| 97 | 97 |          'for')  echo four;;
 | 
	
		
			
			| 98 | 98 |          fif)    echo five;;
 | 
	
		
			
			| 99 | 99 |          eigh)   echo eight;;
 | 
	
		
			
			| 100 |  | -        *)      echo $prefix;;
 | 
	
		
			
			|  | 100 | +        *)      echo "$prefix";;
 | 
	
		
			
			| 101 | 101 |      esac
 | 
	
		
			
			| 102 | 102 |  }
 | 
	
		
			
			| 103 | 103 |  
 | 
	
	
		
			
			|  | @@ -112,14 +112,14 @@ grammar() {
 | 
	
		
			
			| 112 | 112 |          case "$line" in
 | 
	
		
			
			| 113 | 113 |              *"one of those bottles"*)   line="$(
 | 
	
		
			
			| 114 | 114 |                                              [ $oneBottle = true ] \
 | 
	
		
			
			| 115 |  | -                                             && echo ${line/one of those bottles/that lone bottle} \
 | 
	
		
			
			| 116 |  | -                                             || echo $line
 | 
	
		
			
			|  | 115 | +                                             && echo "${line/one of those bottles/that lone bottle}" \
 | 
	
		
			
			|  | 116 | +                                             || echo "$line"
 | 
	
		
			
			| 117 | 117 |                                          )"
 | 
	
		
			
			| 118 | 118 |                                          ;;
 | 
	
		
			
			| 119 | 119 |              *"one down"*)               line="$(
 | 
	
		
			
			| 120 | 120 |                                              [ $oneBottle = true ] \
 | 
	
		
			
			| 121 |  | -                                             && echo ${line/one down/it down} \
 | 
	
		
			
			| 122 |  | -                                             || echo $line
 | 
	
		
			
			|  | 121 | +                                             && echo "${line/one down/it down}" \
 | 
	
		
			
			|  | 122 | +                                             || echo "$line"
 | 
	
		
			
			| 123 | 123 |                                          )"
 | 
	
		
			
			| 124 | 124 |                                          ;;
 | 
	
		
			
			| 125 | 125 |              *bottles*)                  oneBottle=false;;
 | 
	
	
		
			
			|  | @@ -127,7 +127,7 @@ grammar() {
 | 
	
		
			
			| 127 | 127 |          esac
 | 
	
		
			
			| 128 | 128 |          #Some say the twenties should have no hyphen
 | 
	
		
			
			| 129 | 129 |          line="${line/twenty-/twenty }"
 | 
	
		
			
			| 130 |  | -        echo $line
 | 
	
		
			
			|  | 130 | +        echo "$line"
 | 
	
		
			
			| 131 | 131 |      done
 | 
	
		
			
			| 132 | 132 |  }
 | 
	
		
			
			| 133 | 133 |  
 | 
	
	
		
			
			|  | @@ -137,8 +137,8 @@ capitalize() {
 | 
	
		
			
			| 137 | 137 |      #
 | 
	
		
			
			| 138 | 138 |      local line      # every line
 | 
	
		
			
			| 139 | 139 |      while read line; do
 | 
	
		
			
			| 140 |  | -        echo -n ${line:0:1} | tr '[:lower:]' '[:upper:]'
 | 
	
		
			
			| 141 |  | -        echo ${line#?}
 | 
	
		
			
			|  | 140 | +        echo -n "${line:0:1}" | tr '[:lower:]' '[:upper:]'
 | 
	
		
			
			|  | 141 | +        echo "${line#?}"
 | 
	
		
			
			| 142 | 142 |      done
 | 
	
		
			
			| 143 | 143 |  }
 | 
	
		
			
			| 144 | 144 |  
 | 
	
	
		
			
			|  | @@ -149,9 +149,9 @@ punctuate() {
 | 
	
		
			
			| 149 | 149 |      local line      # every line
 | 
	
		
			
			| 150 | 150 |      while read line; do
 | 
	
		
			
			| 151 | 151 |          case "${line}" in
 | 
	
		
			
			| 152 |  | -            [Ii]f*)     echo ${line},;;
 | 
	
		
			
			|  | 152 | +            [Ii]f*)     echo "${line},";;
 | 
	
		
			
			| 153 | 153 |              '')         echo;;
 | 
	
		
			
			| 154 |  | -            *)          echo ${line}.;;
 | 
	
		
			
			|  | 154 | +            *)          echo "${line}.";;
 | 
	
		
			
			| 155 | 155 |          esac
 | 
	
		
			
			| 156 | 156 |      done
 | 
	
		
			
			| 157 | 157 |  }
 | 
	
	
		
			
			|  | @@ -161,16 +161,16 @@ verse() {
 | 
	
		
			
			| 161 | 161 |      # Write one verse with number $1
 | 
	
		
			
			| 162 | 162 |      #
 | 
	
		
			
			| 163 | 163 |      local nb=$1     # numeral
 | 
	
		
			
			| 164 |  | -    echo $nb bottles of beer on the wall
 | 
	
		
			
			| 165 |  | -    echo $nb bottles of beer
 | 
	
		
			
			| 166 |  | -    if [ $nb = zero ]; then
 | 
	
		
			
			| 167 |  | -        echo Go to the store and buy some more
 | 
	
		
			
			|  | 164 | +    echo "$nb bottles of beer on the wall"
 | 
	
		
			
			|  | 165 | +    echo "$nb bottles of beer"
 | 
	
		
			
			|  | 166 | +    if [ "$nb" = zero ]; then
 | 
	
		
			
			|  | 167 | +        echo "Go to the store and buy some more"
 | 
	
		
			
			| 168 | 168 |          nb=ninety-nine
 | 
	
		
			
			| 169 | 169 |      else
 | 
	
		
			
			| 170 |  | -        echo $breakLine
 | 
	
		
			
			| 171 |  | -        nb=$(pred $nb)
 | 
	
		
			
			|  | 170 | +        echo "$breakLine"
 | 
	
		
			
			|  | 171 | +        nb=$(pred "$nb")
 | 
	
		
			
			| 172 | 172 |      fi
 | 
	
		
			
			| 173 |  | -    echo $nb bottles of beer on the wall
 | 
	
		
			
			|  | 173 | +    echo "$nb bottles of beer on the wall"
 | 
	
		
			
			| 174 | 174 |  }
 | 
	
		
			
			| 175 | 175 |  
 | 
	
		
			
			| 176 | 176 |  poeticize() {
 | 
	
	
		
			
			|  | @@ -184,13 +184,13 @@ poeticize() {
 | 
	
		
			
			| 184 | 184 |          case "$rest" in
 | 
	
		
			
			| 185 | 185 |              *beer*)
 | 
	
		
			
			| 186 | 186 |                  first=${first/zero/no}
 | 
	
		
			
			| 187 |  | -                syl=$(syllables ${first% *})
 | 
	
		
			
			|  | 187 | +                syl=$(syllables "${first% *}")
 | 
	
		
			
			| 188 | 188 |                  case $syl in  #improve meter
 | 
	
		
			
			| 189 |  | -                    1|2)    echo $first 'more' $rest;;
 | 
	
		
			
			| 190 |  | -                    *)      echo $first $rest;;
 | 
	
		
			
			|  | 189 | +                    1|2)    echo "$first more $rest";;
 | 
	
		
			
			|  | 190 | +                    *)      echo "$first $rest" ;;
 | 
	
		
			
			| 191 | 191 |                  esac
 | 
	
		
			
			| 192 | 192 |                  ;;
 | 
	
		
			
			| 193 |  | -            *)  echo $first $rest
 | 
	
		
			
			|  | 193 | +            *)  echo "$first $rest"
 | 
	
		
			
			| 194 | 194 |          esac
 | 
	
		
			
			| 195 | 195 |      done
 | 
	
		
			
			| 196 | 196 |  }
 | 
	
	
		
			
			|  | @@ -210,7 +210,7 @@ syllables() {
 | 
	
		
			
			| 210 | 210 |      case $word in
 | 
	
		
			
			| 211 | 211 |          *seven*)    let $((n = n+1));;
 | 
	
		
			
			| 212 | 212 |      esac
 | 
	
		
			
			| 213 |  | -    echo $n
 | 
	
		
			
			|  | 213 | +    echo "$n"
 | 
	
		
			
			| 214 | 214 |  }
 | 
	
		
			
			| 215 | 215 |  
 | 
	
		
			
			| 216 | 216 |  main() {
 | 
	
	
		
			
			|  | @@ -222,14 +222,14 @@ main() {
 | 
	
		
			
			| 222 | 222 |      wastefulBreakLine="If one of those bottles should happen to fall"
 | 
	
		
			
			| 223 | 223 |      breakLine=$(
 | 
	
		
			
			| 224 | 224 |          [ "$1" = --careless ] \
 | 
	
		
			
			| 225 |  | -         && echo $wastefulBreakLine \
 | 
	
		
			
			| 226 |  | -         || echo $standardBreakLine
 | 
	
		
			
			|  | 225 | +         && echo "$wastefulBreakLine" \
 | 
	
		
			
			|  | 226 | +         || echo "$standardBreakLine"
 | 
	
		
			
			| 227 | 227 |      )
 | 
	
		
			
			| 228 | 228 |      nb=ninety-nine
 | 
	
		
			
			| 229 | 229 |      while [ -n "$nb" ]; do
 | 
	
		
			
			| 230 |  | -        verse $nb
 | 
	
		
			
			|  | 230 | +        verse "$nb"
 | 
	
		
			
			| 231 | 231 |          echo
 | 
	
		
			
			| 232 |  | -        nb=$(pred $nb)
 | 
	
		
			
			|  | 232 | +        nb=$(pred "$nb")
 | 
	
		
			
			| 233 | 233 |      done | poeticize | grammar | punctuate | capitalize
 | 
	
		
			
			| 234 | 234 |  }
 | 
	
		
			
			| 235 | 235 |  
 |