2N/A#! @builddir@/grub-shell-tester
2N/A
2N/A# Run GRUB script in a Qemu instance
2N/A# Copyright (C) 2010 Free Software Foundation, Inc.
2N/A#
2N/A# GRUB is free software: you can redistribute it and/or modify
2N/A# it under the terms of the GNU General Public License as published by
2N/A# the Free Software Foundation, either version 3 of the License, or
2N/A# (at your option) any later version.
2N/A#
2N/A# GRUB is distributed in the hope that it will be useful,
2N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A# GNU General Public License for more details.
2N/A#
2N/A# You should have received a copy of the GNU General Public License
2N/A# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A
2N/Aecho parameter count
2N/Afunction fcount {
2N/A echo fcount "$#"
2N/A}
2N/A
2N/Afcount
2N/Afcount a
2N/Afcount a b
2N/A
2N/Aecho parameter count, with nesting
2N/Afunction ffcount {
2N/A echo ffcount "$#"
2N/A fcount
2N/A fcount a
2N/A fcount a b
2N/A}
2N/A
2N/Affcount
2N/Affcount 1
2N/Affcount 1 2
2N/A
2N/Aecho parameters
2N/Afunction fparam {
2N/A echo fparam 1 $1
2N/A echo fparam 2 $2
2N/A echo fparam 3 $3
2N/A}
2N/A
2N/Afparam
2N/Afparam a
2N/Afparam a b
2N/A
2N/Aecho parameters, with nesting
2N/Afunction ffparam {
2N/A echo ffparam 1 $1
2N/A echo ffparam 2 $2
2N/A echo ffparam 3 $3
2N/A fparam
2N/A fparam a
2N/A fparam a b
2N/A}
2N/A
2N/Affparam
2N/Affparam 1
2N/Affparam 1 2
2N/A
2N/Aecho parameter expansion with specials
2N/Afunction fstar {
2N/A for f in $*
2N/A do
2N/A echo fstar $f
2N/A done
2N/A
2N/A for f in aaa$*bbb
2N/A do
2N/A echo fstar $f
2N/A done
2N/A}
2N/A
2N/Afstar
2N/Afstar a
2N/Afstar a "1 2"
2N/Afstar a "1 2" b
2N/A
2N/Afunction fdqstar {
2N/A for f in "$*"
2N/A do
2N/A echo fdqstar $f
2N/A done
2N/A
2N/A for f in aaa"$*"bbb
2N/A do
2N/A echo fdqstar $f
2N/A done
2N/A
2N/A for f in "aaa$*bbb"
2N/A do
2N/A echo fdqstar $f
2N/A done
2N/A}
2N/A
2N/Afdqstar
2N/Afdqstar a
2N/Afdqstar a "1 2"
2N/Afdqstar a "1 2" b
2N/A
2N/Afunction fat {
2N/A for f in $@
2N/A do
2N/A echo fat $f
2N/A done
2N/A
2N/A for f in aaa$@bbb
2N/A do
2N/A echo fat $f
2N/A done
2N/A}
2N/A
2N/Afat
2N/Afat a
2N/Afat a "1 2"
2N/Afat a "1 2" b
2N/Afat a "1 2" b "c d"
2N/Afat a "1 2" b "c d" e
2N/A
2N/Afunction fdqat {
2N/A for f in "$@"
2N/A do
2N/A echo fdqat $f
2N/A done
2N/A
2N/A for f in aaa"$@"bbb
2N/A do
2N/A echo fdqat $f
2N/A done
2N/A
2N/A for f in "aaa$@bbb"
2N/A do
2N/A echo fdqat $f
2N/A done
2N/A}
2N/A
2N/A# fdqat # this case needs special handling, lets ignore till we really need it.
2N/Afdqat a
2N/Afdqat a "1 2"
2N/Afdqat a "1 2" b
2N/Afdqat a "1 2" b "c d"
2N/Afdqat a "1 2" b "c d" e
2N/A