]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commit
uboot-sign.bbclass: Refactor condition checks to use && and || instead of -a and -o
authorJamin Lin <jamin_lin@aspeedtech.com>
Tue, 17 Jun 2025 08:10:51 +0000 (16:10 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 19 Jun 2025 10:05:42 +0000 (11:05 +0100)
commitd2740e39800a044d557b620e38ca0ac1b8c6d030
tree026554fdb6de54075b9841d0937db64045acea91
parent7ad6acd8841752a5b75b8e2666bca5b609347cc1
uboot-sign.bbclass: Refactor condition checks to use && and || instead of -a and -o

This commit cleans up and modernizes the shell condition expressions in
`uboot-sign.bbclass` to follow best practices for portable and reliable shell usage.

Key changes:
- Replace legacy `[ -a ]` and `[ -o ]` with explicit `[ ] && [ ]` and `[ ] || [ ]`.
  Modern POSIX and busybox sh recommend using `&&` and `||` instead of `-a` and `-o`
  because `-a` and `-o` are less robust and can cause parsing ambiguities in some shells.
- Simplify `concat_dtb()` by moving the DTB existence check to the top and using
  early `return` to avoid deep nesting.
- Remove redundant fallback `else` blocks; use clearer control flow with direct checks.

This improves maintainability, reduces shell syntax pitfalls, and aligns with
current shell scripting best practices.

References:
- POSIX recommends avoiding `-a` and `-o` in `[ ]` and using explicit `&&` and `||`:
  https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/uboot-sign.bbclass