Skip to content

Commit af34815

Browse files
HeyMecoleggewie
authored andcommitted
Apply coderabbit suggestion: Guard against errexit on missing sfdisk
Use a presence check before version parsing.
1 parent 6e342b7 commit af34815

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

extensions/ufs.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
function extension_prepare_config__ufs {
33
# Check sfdisk version is >= 2.41 for UFS support
44
local sfdisk_version
5-
sfdisk_version=$(sfdisk --version | awk '/util-linux/ {print $NF}')
5+
if ! command -v sfdisk >/dev/null 2>&1; then
6+
exit_with_error "sfdisk not found. Please install util-linux (provides sfdisk) >= 2.41."
7+
fi
8+
# Extract the util-linux version and strip any non-numeric characters for robustness
9+
sfdisk_version="$(sfdisk --version 2>/dev/null | awk '/util-linux/ {print $NF}' | tr -cd '0-9.')"
610
if [[ -z "${sfdisk_version}" ]]; then
7-
exit_with_error "sfdisk not found - please install util-linux / fdisk >= 2.41 package"
11+
exit_with_error "Unable to determine util-linux version from 'sfdisk --version'."
812
fi
913
if linux-version compare "${sfdisk_version}" lt "2.41"; then
1014
exit_with_error "UFS extension requires sfdisk >= 2.41 (from util-linux). Current version: ${sfdisk_version}"

0 commit comments

Comments
 (0)