From 929faf54e7148d77c163802626119a25930bbe306caf699166b0d351e8f69c4e Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Fri, 21 Feb 2014 03:09:36 +0000 Subject: [PATCH] Accepting request 223241 from home:jnweiger:branches:Base:System - updating grub2-once - added --list switch. - improved --help and error handling. OBS-URL: https://build.opensuse.org/request/show/223241 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=77 --- 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