stdenv/setup.sh: fix isMachO detection after bash-5.3 update

Without the change isMachO fails to work on UTF-8 locales as `read -u 4`
decoders 4 UTF-8 chars and not 4 bytes. `LANG=C` forces it to read bytes.

Closes: https://github.com/NixOS/nixpkgs/issues/431934
This commit is contained in:
Sergei Trofimovich
2025-08-08 21:52:43 +01:00
parent 05a0ed4534
commit ab4295ea0f
+3 -3
View File
@@ -519,7 +519,7 @@ isELF() {
local fd
local magic
exec {fd}< "$fn"
read -r -n 4 -u "$fd" magic
LANG=C read -r -n 4 -u "$fd" magic
exec {fd}<&-
if [ "$magic" = $'\177ELF' ]; then return 0; else return 1; fi
}
@@ -530,7 +530,7 @@ isMachO() {
local fd
local magic
exec {fd}< "$fn"
read -r -n 4 -u "$fd" magic
LANG=C read -r -n 4 -u "$fd" magic
exec {fd}<&-
# nix uses 'declare -F' in get-env.sh to retrieve the loaded functions.
@@ -559,7 +559,7 @@ isScript() {
local fd
local magic
exec {fd}< "$fn"
read -r -n 2 -u "$fd" magic
LANG=C read -r -n 2 -u "$fd" magic
exec {fd}<&-
if [[ "$magic" =~ \#! ]]; then return 0; else return 1; fi
}