Skip to content

Commit b98c6eb

Browse files
Cyanoxygenchenx97
authored andcommitted
commands: add new command 'pause'
- Simple enough, this command prints out a prompt, either pre-defined or user specified, and awaits a key stroke from the user.
1 parent 71cb4fc commit b98c6eb

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

grub-core/Makefile.core.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,11 @@ module = {
10581058
common = commands/password_pbkdf2.c;
10591059
};
10601060

1061+
module = {
1062+
name = pause;
1063+
common = commands/pause.c;
1064+
};
1065+
10611066
module = {
10621067
name = play;
10631068
x86 = commands/i386/pc/play.c;

grub-core/commands/pause.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* pause.c - Wait for a keystroke with or without custom messages */
2+
/*
3+
* GRUB -- GRand Unified Bootloader
4+
* Copyright (C) 2006,2007,2010 Free Software Foundation, Inc.
5+
*
6+
* GRUB is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* GRUB is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include <grub/dl.h>
21+
#include <grub/misc.h>
22+
#include <grub/extcmd.h>
23+
#include <grub/err.h>
24+
#include <grub/i18n.h>
25+
#include <grub/term.h>
26+
27+
GRUB_MOD_LICENSE ("GPLv3+");
28+
29+
static grub_err_t
30+
grub_cmd_pause (grub_extcmd_context_t ctxt __attribute__ ((unused)),
31+
int argc, char **args)
32+
{
33+
if (argc != 1)
34+
grub_printf ("%s", N_("Press any key to continue..."));
35+
else
36+
grub_printf ("%s", args[0]);
37+
38+
(void) grub_getkey ();
39+
return GRUB_ERR_NONE;
40+
}
41+
42+
static grub_extcmd_t cmd;
43+
44+
GRUB_MOD_INIT(pause)
45+
{
46+
cmd = grub_register_extcmd ("pause", grub_cmd_pause, 0,
47+
"STRING", N_("Wait for a key stroke with a message."),
48+
0);
49+
}
50+
51+
GRUB_MOD_FINI(pause)
52+
{
53+
grub_unregister_extcmd (cmd);
54+
}

0 commit comments

Comments
 (0)