main.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2009 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. #include <grub/dl.h>
  19. #include <grub/parser.h>
  20. #include <grub/script_sh.h>
  21. static grub_err_t
  22. grub_normal_parse_line (char *line, grub_reader_getline_t getline,
  23. void *closure)
  24. {
  25. struct grub_script *parsed_script;
  26. /* Parse the script. */
  27. parsed_script = grub_script_parse (line, getline, closure);
  28. if (parsed_script)
  29. {
  30. /* Execute the command(s). */
  31. grub_script_execute (parsed_script);
  32. /* The parsed script was executed, throw it away. */
  33. grub_script_free (parsed_script);
  34. }
  35. return grub_errno;
  36. }
  37. static struct grub_parser grub_sh_parser =
  38. {
  39. .name = "grub",
  40. .parse_line = grub_normal_parse_line
  41. };
  42. GRUB_MOD_INIT(sh)
  43. {
  44. grub_parser_register ("grub", &grub_sh_parser);
  45. }
  46. GRUB_MOD_FINI(sh)
  47. {
  48. grub_parser_unregister (&grub_sh_parser);
  49. }