[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a1fb08a30cbd6682e3ca218447573d4c62034003.1760658427.git.kevin@kevinlocke.name>
Date: Thu, 16 Oct 2025 17:47:09 -0600
From: Kevin Locke <kevin@...inlocke.name>
To: Jonathan Corbet <corbet@....net>,
Randy Dunlap <rdunlap@...radead.org>,
Thorsten Leemhuis <linux@...mhuis.info>,
David Laight <david.laight.linux@...il.com>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH] tools: remove unnecessary x suffix in test strings
An "x" suffix was appended to test variable expansions, presumably to
avoid issues with empty strings in some old shells, or perhaps with the
intention of avoiding issues with dashes or other special characters
that an "x" prefix might have avoided. In either case, POSIX ensures
that such protections are not necessary, and are unlikely to be
encountered in shells currently in use, as indicated by shellcheck
SC2268.
Remove the "x" suffixes which unnecessarily complicate the code.
Signed-off-by: Kevin Locke <kevin@...inlocke.name>
Suggested-by: David Laight <david.laight.linux@...il.com>
---
Thanks David, that's a good point about the x suffixes. Since
shellcheck warns about the x prefixes (SC2268) and I'm not aware of any
shells currently in use which require them, I think they are safe to
remove to clean up the code a bit. Here's a patch to do just that,
which can be applied on top of my previous patch.
Since -o is an XSI extension to POSIX, I've stuck with ||, but I think
you are right that x would not be required in that case either.
Thanks again,
Kevin
tools/debugging/kernel-chktaint | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/debugging/kernel-chktaint b/tools/debugging/kernel-chktaint
index 051608a63d9f..051ac27b58eb 100755
--- a/tools/debugging/kernel-chktaint
+++ b/tools/debugging/kernel-chktaint
@@ -18,8 +18,8 @@ retrieved from /proc/sys/kernel/tainted on another system.
EOF
}
-if [ "$1"x != "x" ]; then
- if [ "$1"x = "--helpx" ] || [ "$1"x = "-hx" ] ; then
+if [ "$1" != "" ]; then
+ if [ "$1" = "--help" ] || [ "$1" = "-h" ] ; then
usage
exit 1
elif [ $1 -ge 0 ] 2>/dev/null ; then
--
2.51.0
Powered by blists - more mailing lists