gnuboot-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1 2/5] resources: grub: config: (ab)use shellcheck to check it.


From: Denis 'GNUtoo' Carikli
Subject: [PATCH v1 2/5] resources: grub: config: (ab)use shellcheck to check it.
Date: Fri, 13 Dec 2024 14:58:48 +0100

While the grub configuration file format is very different from real
shell scripts, the similarities are enough to make it pass shellcheck
with very few adjustements.

The advantage of using shellcheck here is that we can still detect
some issues such as variables that are referenced but not assigned.

For instance if we add 'echo "$test"' in the beginning of the
configuration file we then have:
    In resources/grub/config/grub.cfg line 24:
    echo "$test"
          ^---^ SC2154 (warning): test is referenced but not assigned
          (for output from commands, use "$(test ...)" ).

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
---
 resources/grub/config/grub.cfg | 4 ++++
 tests/lint                     | 1 +
 2 files changed, 5 insertions(+)

diff --git a/resources/grub/config/grub.cfg b/resources/grub/config/grub.cfg
index 511e4ced..08ba7c0b 100644
--- a/resources/grub/config/grub.cfg
+++ b/resources/grub/config/grub.cfg
@@ -1,3 +1,4 @@
+# shellcheck disable=SC2148 # Does not check for #!
 # Copyright (C) 2013, 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
 # Copyright (C) 2013-2016, 2020-2021 Leah Rowe <leah@libreboot.org>
 # Copyright (C) 2021 Vitali64 <vitali64pmemail@protonmail.com>
@@ -16,6 +17,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
+# shellcheck disable=SC2121 # warn against set var=val
+# shellcheck disable=SC1036 # error: invalid '('
+# shellcheck disable=SC1088 # error: invalid uses of parentheses
 set prefix=(memdisk)/boot/grub
 
 insmod at_keyboard
diff --git a/tests/lint b/tests/lint
index df7b8a22..2f81b8aa 100755
--- a/tests/lint
+++ b/tests/lint
@@ -46,6 +46,7 @@ run_shellcheck \
     download \
     modify \
     update \
+    resources/grub/config/grub.cfg \
     resources/packages/coreboot/distclean \
     resources/packages/descriptors/distclean \
     resources/packages/grub/distclean \
-- 
2.46.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]