grub_script_functions.in 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #! @builddir@/grub-shell-tester
  2. # Run GRUB script in a Qemu instance
  3. # Copyright (C) 2010 Free Software Foundation, Inc.
  4. #
  5. # GRUB is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # GRUB is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. echo parameter count
  18. function fcount {
  19. echo fcount "$#"
  20. }
  21. fcount
  22. fcount a
  23. fcount a b
  24. echo parameter count, with nesting
  25. function ffcount {
  26. echo ffcount "$#"
  27. fcount
  28. fcount a
  29. fcount a b
  30. }
  31. ffcount
  32. ffcount 1
  33. ffcount 1 2
  34. echo parameters
  35. function fparam {
  36. echo fparam 1 $1
  37. echo fparam 2 $2
  38. echo fparam 3 $3
  39. }
  40. fparam
  41. fparam a
  42. fparam a b
  43. echo parameters, with nesting
  44. function ffparam {
  45. echo ffparam 1 $1
  46. echo ffparam 2 $2
  47. echo ffparam 3 $3
  48. fparam
  49. fparam a
  50. fparam a b
  51. }
  52. ffparam
  53. ffparam 1
  54. ffparam 1 2
  55. echo parameter expansion with specials
  56. function fstar {
  57. for f in $*
  58. do
  59. echo fstar $f
  60. done
  61. for f in aaa$*bbb
  62. do
  63. echo fstar $f
  64. done
  65. }
  66. fstar
  67. fstar a
  68. fstar a "1 2"
  69. fstar a "1 2" b
  70. function fdqstar {
  71. for f in "$*"
  72. do
  73. echo fdqstar $f
  74. done
  75. for f in aaa"$*"bbb
  76. do
  77. echo fdqstar $f
  78. done
  79. for f in "aaa$*bbb"
  80. do
  81. echo fdqstar $f
  82. done
  83. }
  84. fdqstar
  85. fdqstar a
  86. fdqstar a "1 2"
  87. fdqstar a "1 2" b
  88. function fat {
  89. for f in $@
  90. do
  91. echo fat $f
  92. done
  93. for f in aaa$@bbb
  94. do
  95. echo fat $f
  96. done
  97. }
  98. fat
  99. fat a
  100. fat a "1 2"
  101. fat a "1 2" b
  102. fat a "1 2" b "c d"
  103. fat a "1 2" b "c d" e
  104. function fdqat {
  105. for f in "$@"
  106. do
  107. echo fdqat $f
  108. done
  109. for f in aaa"$@"bbb
  110. do
  111. echo fdqat $f
  112. done
  113. for f in "aaa$@bbb"
  114. do
  115. echo fdqat $f
  116. done
  117. }
  118. # fdqat # this case needs special handling, lets ignore till we really need it.
  119. fdqat a
  120. fdqat a "1 2"
  121. fdqat a "1 2" b
  122. fdqat a "1 2" b "c d"
  123. fdqat a "1 2" b "c d" e