ソースを参照

Introduce globals for demonstration

Alois Mahdal 3 年 前
コミット
7a1a1a3c0e
共有1 個のファイルを変更した22 個の追加2 個の削除を含む
  1. 22
    2
      99bottles.sh

+ 22
- 2
99bottles.sh ファイルの表示

@@ -16,6 +16,26 @@
16 16
 #   [99b]: http://99-bottles-of-beer.net/language-bash-1831.html
17 17
 #
18 18
 
19
+#
20
+# Default transition mode
21
+#
22
+# 'standard' to use the standard form; 'careless' to have the
23
+# song consider effects of gravity on the bottles.
24
+#
25
+# Default is 'standard'.
26
+#
27
+NN_BOTTLES__MODE=${NN_BOTTLES__MODE:-standard}
28
+
29
+#
30
+# Starting bottle amount
31
+#
32
+# Initial amount of bottles specified as numeral.  Numerals up
33
+# to 99 are supported.
34
+#
35
+# Default is 'ninety-nine'.
36
+#
37
+NN_STARTING_AMOUNT=${NN_STARTING_AMOUNT:-ninety-nine}
38
+
19 39
 pred() {
20 40
     #
21 41
     # Get predecessor to a number $1
@@ -215,8 +235,8 @@ syllables() {
215 235
 
216 236
 main() {
217 237
     local TransitionLine    # transition line between verses
218
-    local togo              # bottles to go
219
-    local mode=standard     # transition mode
238
+    local togo=$NN_STARTING_AMOUNT  # bottles to go
239
+    local mode=$NN_BOTTLES__MODE    # transition mode
220 240
     while true; do case $1 in
221 241
         --careless)     mode=careless; shift ;;
222 242
         *)              break ;;