From 0e20bc80a56397d9c476522886c1032881e0911586553edd9b296827d356a619 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Sat, 22 Feb 2014 19:44:15 +0000 Subject: [PATCH] Accepting request 223322 from Base:System - updating grub2-once - added --list switch. - improved --help and error handling. (forwarded request 223241 from jnweiger) OBS-URL: https://build.opensuse.org/request/show/223322 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/grub2?expand=0&rev=86 --- grub2-once | 28 +++++++++++++++++++++++++--- grub2.changes | 7 +++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/grub2-once b/grub2-once index 2ed9488..0206fdb 100644 --- a/grub2-once +++ b/grub2-once @@ -1,4 +1,8 @@ #!/usr/bin/perl +# +# (C) 2014 mchang@suse.com +# +# 2014-02-20 jw@suse.de use strict; @@ -37,9 +41,9 @@ if (@ARGV == 2 && ($ARGV[0] eq "--show-mapped")) { $id_name = $ARGV[0]; } -die "wrong command line options" if ($id_name eq ""); +die "wrong command line options, try --help\n" if ($id_name eq ""); -open(SYSCONF, ") { @@ -55,9 +59,16 @@ while () { close (SYSCONF); +if ($id_name eq "--help" or $id_name eq "-h") + { + print "Usage: grub2-once [--show-mapped ID | --list | ID | NAME_SUBSTRING ]\n"; + system "$grub2_reboot \"--help\""; + exit 0; + } + die "no grub2_dir" if ($grub2_dir eq ""); -open(MENU, "<$grub2_dir/grub.cfg") || die "no grub.cfg in $grub2_dir"; +open(MENU, "<$grub2_dir/grub.cfg") || die "cannot read grub.cfg in $grub2_dir: $!\n"; undef $/; while () { @@ -70,6 +81,17 @@ my $ret = ""; my $name = ""; my $id = -1; +if ($id_name eq '--list') + { + my $c = 0; + foreach my $e (@menuentry) + { + printf "%6d %s\n", $c, $e; + $c++; + } + exit 0; + } + if ($id_name =~ m!^[0-9]+$!) { if ($id_name < @menuentry) { diff --git a/grub2.changes b/grub2.changes index e0bb34e..eed42eb 100644 --- a/grub2.changes +++ b/grub2.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Feb 20 14:43:21 UTC 2014 - jw@suse.com + +- updating grub2-once + - added --list switch. + - improved --help and error handling. + ------------------------------------------------------------------- Tue Feb 11 03:02:21 UTC 2014 - mchang@suse.com