From 504ccc45d2dbaaa3ff138d3f86bc61896e6367d2 Mon Sep 17 00:00:00 2001 From: cantalupo555 Date: Mon, 29 Dec 2025 23:05:07 -0300 Subject: [PATCH] fix: replace comm with grep to support uutils coreutils MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ubuntu 25.04+ replaced GNU coreutils with uutils coreutils, a Rust-based reimplementation of Unix core utilities. These are different projects with the same package name: - GNU coreutils 9.x (C) - Ubuntu ≤24.04 - uutils coreutils 0.x (Rust) - Ubuntu ≥25.04 The uutils comm doesn't recognize sort output as sorted, causing "comm: file is not in sorted order" errors. Replace comm patterns with: - grep -vxFf for set difference (lines in B but not in A) - sort | uniq -d for finding duplicates These alternatives don't depend on comm, ensuring compatibility with both GNU and uutils coreutils. --- extensions/gen-sample-extension-docs.sh | 3 ++- lib/functions/general/extensions.sh | 4 ++-- lib/functions/logging/capture.sh | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/extensions/gen-sample-extension-docs.sh b/extensions/gen-sample-extension-docs.sh index e19c430a3..10f0e21aa 100644 --- a/extensions/gen-sample-extension-docs.sh +++ b/extensions/gen-sample-extension-docs.sh @@ -49,7 +49,8 @@ MASTER_HEADER [[ $HOOK_POINT_CALLS_COUNT -gt $HOOK_POINT_CALLS_UNIQUE_COUNT ]] && { # Some hook points were called multiple times, determine which. - HOOK_POINTS_WITH_MULTIPLE_CALLS=$(comm -13 <(sort < "${EXTENSION_MANAGER_TMP_DIR}/hook_point_calls.txt" | uniq) <(sort < "${EXTENSION_MANAGER_TMP_DIR}/hook_point_calls.txt") | sort | uniq | xargs echo -n) + # Find duplicates without comm (uutils coreutils compatible) + HOOK_POINTS_WITH_MULTIPLE_CALLS=$(sort < "${EXTENSION_MANAGER_TMP_DIR}/hook_point_calls.txt" | uniq -d | xargs echo -n) cat << MULTIPLE_CALLS_WARNING - *Important:* The following hook points where called multiple times during the documentation generation. This can be indicative of a bug in the build system. Please check the sources for the invocation of the following hooks: \`${HOOK_POINTS_WITH_MULTIPLE_CALLS}\`. diff --git a/lib/functions/general/extensions.sh b/lib/functions/general/extensions.sh index 8661a5369..acfb3dcef 100644 --- a/lib/functions/general/extensions.sh +++ b/lib/functions/general/extensions.sh @@ -510,8 +510,8 @@ function enable_extension() { after_function_list="$(compgen -A function)" # compare before and after, thus getting the functions defined by the extension. - # comm is oldskool. we like it. go "man comm" to understand -13 below - new_function_list="$(comm -13 <(echo "$before_function_list" | sort) <(echo "$after_function_list" | sort))" + # Avoid comm for uutils coreutils compatibility + new_function_list="$(grep -vxFf <(echo "$before_function_list") <(echo "$after_function_list") || true)" # iterate over defined functions, store them in global associative array extension_function_info for newly_defined_function in ${new_function_list}; do diff --git a/lib/functions/logging/capture.sh b/lib/functions/logging/capture.sh index 47ac3f214..0d8004350 100644 --- a/lib/functions/logging/capture.sh +++ b/lib/functions/logging/capture.sh @@ -18,7 +18,8 @@ function do_capturing_defs() { post_exec_vars="$(compgen -A variable)" - new_vars_list="$(comm -13 <(echo "$pre_exec_vars" | grep -E '[[:upper:]]+' | grep -v -e "^BASH_" | sort) <(echo "${post_exec_vars}" | grep -E '[[:upper:]]+' | grep -v -e "^BASH_" | sort))" + # Avoid comm for uutils coreutils compatibility + new_vars_list="$(grep -vxFf <(echo "$pre_exec_vars" | grep -E '[[:upper:]]+' | grep -v -e "^BASH_") <(echo "${post_exec_vars}" | grep -E '[[:upper:]]+' | grep -v -e "^BASH_") || true)" for onevar in ${new_vars_list}; do all_vars_array+=("$(declare -p "${onevar}")")