grub_cmd_tr.in 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #! @BUILD_SHEBANG@ -e
  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. #
  18. # Translating a string argument
  19. #
  20. cmd='tr 12345 abcde a1b2c3d4e5'
  21. v=`echo "$cmd" | @builddir@/grub-shell`
  22. if test "$v" != aabbccddee; then echo "error: $cmd [$v]" >&2; exit 1; fi
  23. cmd='tr -U abcdABCD'
  24. v=`echo "$cmd" | @builddir@/grub-shell`
  25. if test "$v" != ABCDABCD; then echo "error: $cmd [$v]" >&2; exit 1; fi
  26. cmd='tr -D ABCDabcd'
  27. v=`echo "$cmd" | @builddir@/grub-shell`
  28. if test "$v" != abcdabcd; then echo "error: $cmd [$v]" >&2; exit 1; fi
  29. #
  30. # Translating a variable value
  31. #
  32. cmd='foo=12345678; tr -s foo 1234 abcd; echo $foo'
  33. v=`echo "$cmd" | @builddir@/grub-shell`
  34. if test "$v" != abcd5678; then echo "error: $cmd [$v]" >&2; exit 1; fi
  35. cmd='foo=abcdEFGH; tr -U -s foo; echo $foo'
  36. v=`echo "$cmd" | @builddir@/grub-shell`
  37. if test "$v" != ABCDEFGH; then echo "error: $cmd [$v]" >&2; exit 1; fi
  38. cmd='foo=abcdEFGH; tr -D -s foo; echo $foo'
  39. v=`echo "$cmd" | @builddir@/grub-shell`
  40. if test "$v" != abcdefgh; then echo "error: $cmd [$v]" >&2; exit 1; fi
  41. #
  42. # Setting a variable from string argument
  43. #
  44. cmd='foo=12345678; tr -s foo 1234 abcd a1b2c3d4e5; echo $foo'
  45. v=`echo "$cmd" | @builddir@/grub-shell`
  46. if test "$v" != aabbccdde5; then echo "error: $cmd [$v]" >&2; exit 1; fi
  47. cmd='foo=abcdEFGH; tr -U -s foo xyz; echo $foo'
  48. v=`echo "$cmd" | @builddir@/grub-shell`
  49. if test "$v" != XYZ; then echo "error: $cmd [$v]" >&2; exit 1; fi
  50. cmd='foo=abcdEFGH; tr -D -s foo XYZ; echo $foo'
  51. v=`echo "$cmd" | @builddir@/grub-shell`
  52. if test "$v" != xyz; then echo "error: $cmd [$v]" >&2; exit 1; fi