]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
tests/util/grub-shell: Allow specifying non-default trim line contents
authorGlenn Washburn <development@efficientek.com>
Tue, 10 Jan 2023 22:08:57 +0000 (16:08 -0600)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 19 Jan 2023 16:39:05 +0000 (17:39 +0100)
This will be useful for tests that have unwanted output from setup. This is
not documented because its only intended to be internal at the moment. Also,
--no-trim is allowed to explicitly turn off trim.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
tests/util/grub-shell.in

index 53aa04e3294553bf74d351ce401e0799d4c5d365..8d5d2ce179d4fbc493ce81ad4c453132553ba922 100644 (file)
@@ -32,6 +32,7 @@ PATH="${builddir}:$PATH"
 export PATH
 
 trim=0
+trim_head=664cbea8-132f-4770-8aa4-1696d59ac35c
 
 # Usage: usage
 # Print the usage.
@@ -226,8 +227,13 @@ for option in "$@"; do
        echo "$0 (GNU GRUB ${PACKAGE_VERSION})"
        exit 0 ;;
     --trim)
-       trim=1
+       trim=1 ;;
+    --trim=*)
+       trim=2
+       trim_head=`echo "$option" | sed -e 's/--trim=//' -e 's/,/ /g'`
        ;;
+    --no-trim)
+       trim=0 ;;
     --debug)
         debug=1 ;;
     --modules=*)
@@ -350,8 +356,6 @@ terminal_input ${term}
 terminal_output ${term}
 EOF
 
-trim_head=664cbea8-132f-4770-8aa4-1696d59ac35c
-
 if [ $trim = 1 ]; then
     echo "echo $trim_head" >>${cfgfile}
 fi
@@ -476,8 +480,8 @@ fi
 
 do_trim ()
 {
-    if [ $trim = 1 ]; then
-       awk '{ if (have_head == 1) print $0; } /664cbea8-132f-4770-8aa4-1696d59ac35c/ { have_head=1; }'
+    if [ $trim = 1 ] || [ $trim = 2 ]; then
+       awk '{ if (have_head == 1) print $0; } /'"$trim_head"'/ { have_head=1; }'
     else
        cat
     fi