fix: scope pwntools version probe environment

This commit is contained in:
zhaoxuya520
2026-09-22 05:18:45 +00:00
parent 5f69d6ca24
commit cab634bd85
2 changed files with 11 additions and 3 deletions
+5 -1
View File
@@ -161,7 +161,11 @@ get_tool_version() {
fi
local output
output=$("$cmd" $version_args 2>&1 | head -n1) || true
if [[ "${cmd##*/}" == "pwn" && "$version_args" == "version" ]]; then
output=$(PWNLIB_NOTERM=1 "$cmd" version 2>&1 | head -n1) || true
else
output=$("$cmd" $version_args 2>&1 | head -n1) || true
fi
echo "$output"
}
+6 -2
View File
@@ -33,7 +33,11 @@ run_version() {
echo ""
return 0
fi
"$cmd" "$@" 2>&1 | head -n 1 | tr '\n' ' ' | sed 's/[[:space:]]*$//' || true
if [[ "$cmd" == "pwn" && "$#" -eq 1 && "${1-}" == "version" ]]; then
PWNLIB_NOTERM=1 "$cmd" "$@" 2>&1 | head -n 1 | tr '\n' ' ' | sed 's/[[:space:]]*$//' || true
else
"$cmd" "$@" 2>&1 | head -n 1 | tr '\n' ' ' | sed 's/[[:space:]]*$//' || true
fi
}
file_exists_any() {
@@ -188,7 +192,7 @@ for entry in "${TOOLS[@]}"; do
done
fi
if [[ "$version_spec" != "none" ]]; then
if [[ -n "$version_spec" && "$version_spec" != "none" ]]; then
read -r -a version_parts <<< "$version_spec"
if has_cmd "${version_parts[0]}"; then
version="$(run_version "${version_parts[@]}")"