Skip to contentSkip to conversation

Add --debug to set -x for a few grub commands

PATCH In review Andrew Worsley 2 participants 3 messages May 29, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Add --debug to set -x for a few grub commands

---
 util/grub-kbdcomp.in     | 2 ++
 util/grub-mkconfig.in    | 2 ++
 util/grub-reboot.in      | 2 ++
 util/grub-set-default.in | 2 ++
 4 files changed, 8 insertions(+)
util/grub-kbdcomp.in +2 -0
index a15ec24..74a3ffd 100644
@@ -27,6 +27,7 @@ usage () {
     print_option_help "-h, --help" "$(gettext "print this message and exit")"
     print_option_help "-V, --version" "$(gettext "print the version information and exit")"
     print_option_help "-o, --output=$(gettext FILE)" "$(gettext "save output in FILE [required]")"
+    print_option_help "-d, --debug" "$(gettext "print shell commands as they are run")"
     echo
     gettext_printf "%s generates a keyboard layout for GRUB using ckbcomp\n" "$self"
     echo
@@ -61,6 +62,7 @@ do
 	output=`argument $option "$@"`; shift ;;
     --output=*)
 	output=`echo "$option" | sed 's/--output=//'` ;;
+        -d | --debug) set -x ;;
     *)
 	ckbcomp_options="$ckbcomp_options $option";;
     esac
util/grub-mkconfig.in +2 -0
index f8496d2..2ce73a5 100644
@@ -60,6 +60,7 @@ usage () {
     print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")"
     print_option_help "-h, --help" "$(gettext "print this message and exit")"
     print_option_help "-v, --version" "$(gettext "print the version information and exit")"
+    print_option_help "-d, --debug" "$(gettext "print shell commands as they are run")"
     echo
     gettext "Report bugs to <[email protected]>."; echo
 }
@@ -88,6 +89,7 @@ do
     -V | --version)
 	echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
 	exit 0 ;;
+    -d | --debug) set -x ;;
     -o | --output)
 	grub_cfg=`argument $option "$@"`; shift;;
     --output=*)
util/grub-reboot.in +2 -0
index 4d4f757..c8fa19c 100644
@@ -48,6 +48,7 @@ usage () {
     gettext "Set the default boot menu entry for GRUB, for the next boot only."; echo
     print_option_help "-h, --help" "$(gettext "print this message and exit")"
     print_option_help "-V, --version" "$(gettext "print the version information and exit")"
+    print_option_help "-d, --debug" "$(gettext "print shell commands as they are run")"
     dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
     print_option_help "--boot-directory=$(gettext "DIR")" "$dirmsg"
     echo
@@ -84,6 +85,7 @@ do
     -V | --version)
 	echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
 	exit 0 ;;
+    -d | --debug) set -x ;;
 
 # Accept for compatibility
     --root-directory)
util/grub-set-default.in +2 -0
index 6036f81..ebc3ae9 100644
@@ -50,6 +50,7 @@ usage () {
     echo
     print_option_help "-h, --help" "$(gettext "print this message and exit")"
     print_option_help "-V, --version" "$(gettext "print the version information and exit")"
+    print_option_help "-d, --debug" "$(gettext "print shell commands as they are run")"
     dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
     print_option_help "--boot-directory=$(gettext "DIR")" "$dirmsg"
     echo
@@ -82,6 +83,7 @@ do
     -V | --version)
 	echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
 	exit 0 ;;
+    -d | --debug) set -x ;;
 
 # Accept for compatibility
     --root-directory)
Signature · 1 line
2.1.4
#1 lore raw

What is advantage compared with running scripts with bash -x script name ?

Quoted 114 lines · Andrew Worsley
---
 util/grub-kbdcomp.in     | 2 ++
 util/grub-mkconfig.in    | 2 ++
 util/grub-reboot.in      | 2 ++
 util/grub-set-default.in | 2 ++
 4 files changed, 8 insertions(+)
util/grub-kbdcomp.in +0 -0
index a15ec24..74a3ffd 100644
@@ -27,6 +27,7 @@ usage () {
     print_option_help "-h, --help" "$(gettext "print this message and

exit")"

     print_option_help "-V, --version" "$(gettext "print the version
information and exit")"
     print_option_help "-o, --output=$(gettext FILE)" "$(gettext "save

output in FILE [required]")"
+ print_option_help "-d, --debug" "$(gettext "print shell commands as
they are run")"
echo
gettext_printf "%s generates a keyboard layout for GRUB using
ckbcomp\n" "$self"
echo

util/grub-kbdcomp.in +1 -0
@@ -61,6 +62,7 @@ do
        output=`argument $option "$@"`; shift ;;
     --output=*)
        output=`echo "$option" | sed 's/--output=//'` ;;
+        -d | --debug) set -x ;;
     *)
        ckbcomp_options="$ckbcomp_options $option";;
     esac
util/grub-mkconfig.in +0 -0
index f8496d2..2ce73a5 100644
@@ -60,6 +60,7 @@ usage () {
     print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output

generated config to FILE [default=stdout]")"

     print_option_help "-h, --help" "$(gettext "print this message and
exit")"
     print_option_help "-v, --version" "$(gettext "print the version

information and exit")"
+ print_option_help "-d, --debug" "$(gettext "print shell commands as
they are run")"
echo
gettext "Report bugs to <[email protected]>."; echo
}

util/grub-mkconfig.in +1 -0
@@ -88,6 +89,7 @@ do
     -V | --version)
        echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
        exit 0 ;;
+    -d | --debug) set -x ;;
     -o | --output)
        grub_cfg=`argument $option "$@"`; shift;;
     --output=*)
util/grub-reboot.in +0 -0
index 4d4f757..c8fa19c 100644
@@ -48,6 +48,7 @@ usage () {
     gettext "Set the default boot menu entry for GRUB, for the next boot

only."; echo

     print_option_help "-h, --help" "$(gettext "print this message and
exit")"
     print_option_help "-V, --version" "$(gettext "print the version
information and exit")"
+    print_option_help "-d, --debug" "$(gettext "print shell commands as
they are run")"
     dirmsg="$(gettext_printf "expect GRUB images under the directory
DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
     print_option_help "--boot-directory=$(gettext "DIR")" "$dirmsg"
     echo
util/grub-reboot.in +1 -0
@@ -84,6 +85,7 @@ do
     -V | --version)
        echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
        exit 0 ;;
+    -d | --debug) set -x ;;
 
 # Accept for compatibility
     --root-directory)
util/grub-set-default.in +0 -0
index 6036f81..ebc3ae9 100644
@@ -50,6 +50,7 @@ usage () {
     echo
     print_option_help "-h, --help" "$(gettext "print this message and

exit")"

     print_option_help "-V, --version" "$(gettext "print the version
information and exit")"
+    print_option_help "-d, --debug" "$(gettext "print shell commands as
they are run")"
     dirmsg="$(gettext_printf "expect GRUB images under the directory
DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
     print_option_help "--boot-directory=$(gettext "DIR")" "$dirmsg"
     echo
util/grub-set-default.in +1 -1
@@ -82,6 +83,7 @@ do
     -V | --version)
        echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
        exit 0 ;;
+    -d | --debug) set -x ;;
 
 # Accept for compatibility
     --root-directory)
--

2.1.4

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#2 lore raw
Quoted 2 lines · Vladimir 'phcoder' Serbinenko

What is advantage compared with running scripts with bash -x script name ?

For a naive user they may not even realise it is a shell script or that the running it via bash -x option will give a valuable debug output. I didn't until I did a bunch of work on it. It is an extremely simple addition but very helpful to understand is going on and gives useful debug reports.

I was thinking that we could expand this to have a level with lower levels printing out settings of key variables and a high level generating the -x output. But I think at least having this debug output easily available is an easy but valuable improvement.

Andrew