From 677660c1c62345432611b2e4a2e56439be6826d4 Mon Sep 17 00:00:00 2001 From: Felitendo Date: Thu, 24 Sep 2026 10:23:59 +0200 Subject: [PATCH] fix: start faster by skipping lines scripts do not need --- src/lib/detect.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/detect.sh b/src/lib/detect.sh index a9bad98..a509aad 100644 --- a/src/lib/detect.sh +++ b/src/lib/detect.sh @@ -486,6 +486,11 @@ _mca_script_target() { MCA_SCRIPT_VARS=() + # Only assignments and exec lines matter, and the shell is slow at reading + # a big script line by line. So grep picks them out, and a script with no + # exec at all (winetricks has 20000 lines of that) is not read here at all. + grep -qaE '^[[:space:]]*exec[[:space:]]' -- "$script" 2>/dev/null || return 1 + while IFS= read -r line; do if [[ $line =~ $re_assign ]]; then name="${BASH_REMATCH[2]}" @@ -543,7 +548,8 @@ _mca_script_target() { fi return $? done - done < "$script" + done < <(grep -aE '^[[:space:]]*((export[[:space:]]+)?[A-Za-z_][A-Za-z0-9_]*=|exec[[:space:]])' \ + -- "$script" 2>/dev/null) return 1 }