From 5644aaf03778473d2543702a8672287534dfa016 Mon Sep 17 00:00:00 2001 From: zyliwax Date: Mon, 15 May 2017 20:31:15 +0000 Subject: grubeditor.sh Fixed diff_configs functions that was not deleting tempfiles --- resources/scripts/misc/grubeditor.sh | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'resources') diff --git a/resources/scripts/misc/grubeditor.sh b/resources/scripts/misc/grubeditor.sh index 832e0dc6..6cd2235c 100644 --- a/resources/scripts/misc/grubeditor.sh +++ b/resources/scripts/misc/grubeditor.sh @@ -45,6 +45,7 @@ # # -D | --differ [/path/to/]differ: use /path/to/differ instead of "diff", can # be an interactive program like vimdiff +# # THIS BLOCK IS EXPERIMENTAL # Allow debugging by running DEBUG= ${0}. @@ -53,6 +54,9 @@ # -e kills the script if any function returns not-zero #set -u +# Version number of script +geversion="0.1" + # Define the list of available option in both short and long form. shortopts="hrie:sdD:" longopts="help,realcfg,inplace,editor:,swapcfgs,diffcfgs,differ:" @@ -101,9 +105,14 @@ get_options() { case "$1" in -h|--help) show_help - # I return non-zero here just so nobody thinks we successfully edited grub.cfg + # I return non-zero here just so nobody thinks we successfully edited grub{,test}.cfg exit 200 ;; + -v|--version) + show_version + # I return non-zero here just so nobody thinks we successfully edited grub{,test}.cfg + exit 201 + ;; -r|--realcfg) edit_realcfg=1 shift @@ -307,6 +316,10 @@ existing file HELPSCREEN } +show_version() { + echo "${geversion}" +} + swap_configs() { # Procedure: # 1. Call cbfstool twice, once each to extract grub.cfg and grubtest.cfg. @@ -356,12 +369,19 @@ diff_configs() { # Determine the differ command to use. find_differ + grubcfg="$(random_filer "grubcfg")" + testcfg="$(random_filer "testcfg")" + # Extract config files from provided romfile. - "${cbfstool}" "${romfile}" extract -n grub.cfg -f /tmp/grub_tmpdiff.cfg - "${cbfstool}" "${romfile}" extract -n grubtest.cfg -f /tmp/grubtest_tmpdiff.cfg + "${cbfstool}" "${romfile}" extract -n grub.cfg -f "${grubcfg}" + "${cbfstool}" "${romfile}" extract -n grubtest.cfg -f "${testcfg}" # Run the differ command with real as first option, test as second option. - "${use_differ}" /tmp/grub_tmpdiff.cfg /tmp/grubtest_tmpdiff.cfg + "${use_differ}" "${grubcfg}" "${testcfg}" + + # Delete the temporary copies of the configuration files. + rm "${grubcfg}" + rm "${testcfg}" } edit_config() { -- cgit v1.2.3-54-g00ecf From f32844adeaa97662f2671ae4510054974a0cc90b Mon Sep 17 00:00:00 2001 From: zyliwax Date: Mon, 15 May 2017 20:36:12 +0000 Subject: Upload files to 'resources/scripts/misc' version needed updating --- resources/scripts/misc/grubeditor.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'resources') diff --git a/resources/scripts/misc/grubeditor.sh b/resources/scripts/misc/grubeditor.sh index 6cd2235c..f6ccb728 100644 --- a/resources/scripts/misc/grubeditor.sh +++ b/resources/scripts/misc/grubeditor.sh @@ -55,7 +55,7 @@ #set -u # Version number of script -geversion="0.1" +geversion="0.1.1" # Define the list of available option in both short and long form. shortopts="hrie:sdD:" -- cgit v1.2.3-54-g00ecf