1
/* regexp.c -- The regexp command. */
3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 2005,2007 Free Software Foundation, Inc.
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.
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.
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/>.
21
#include <grub/misc.h>
23
#include <grub/command.h>
24
#include <grub/i18n.h>
28
grub_cmd_regexp (grub_command_t cmd __attribute__ ((unused)),
29
int argc, char **args)
40
return grub_error (GRUB_ERR_BAD_ARGUMENT, "2 arguments expected");
42
ret = regcomp (®ex, args[0], RE_SYNTAX_GNU_AWK);
46
ret = regexec (®ex, args[1], 0, 0, 0);
54
s = regerror (ret, ®ex, 0, 0);
55
comperr = grub_malloc (s);
61
regerror (ret, ®ex, comperr, s);
62
err = grub_error (GRUB_ERR_TEST_FAILURE, "%s", comperr);
68
static grub_command_t cmd;
72
cmd = grub_register_command ("regexp", grub_cmd_regexp,
74
N_("Test if REGEXP matches STRING."));
79
grub_unregister_command (cmd);