From dd90046b703b1a6b32e0d87080ff64ca3645f14c Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Mon, 17 Mar 2025 14:01:02 -0500 Subject: [PATCH] copy-firmware: fail gracefully if moreutils parallel is installed The copy-firmware.sh script can use the "parallel" command to parallelize some operations, but it needs the GNU version of parallel. There is another, simpler version of parallel that is part of the moreutils package, but that version confuses the has_gnu_parallel() function. So first test to make sure that the --version parameter is even recognized before trying to use it. If in the future, moreutils parallel adds support for --version, this script should still work because that version should never report "GNU parallel". Signed-off-by: Timur Tabi --- copy-firmware.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/copy-firmware.sh b/copy-firmware.sh index cd5a6893..6a32127e 100755 --- a/copy-firmware.sh +++ b/copy-firmware.sh @@ -27,6 +27,13 @@ warn() { has_gnu_parallel() { if command -v parallel > /dev/null; then + # The moreutils package comes with a simpler version of "parallel" + # that does not support the --version or -a options. Check for + # that first. In some distros, installing the "parallel" package + # will replace the moreutils version with the GNU version. + if ! parallel --version > /dev/null 2>&1; then + return 1 + fi if parallel --version | grep -Fqi 'gnu parallel'; then return 0 fi