stdenv, swift: Use local fd in is* bash functions for hygiene

This commit is contained in:
John Ericson 2017-06-29 20:28:27 -04:00 committed by John Ericson
parent a14cf06182
commit e57a220f81
2 changed files with 4 additions and 1 deletions

View File

@ -1,12 +1,13 @@
--- swift/utils/build-script-impl 2017-01-23 12:47:20.401326309 -0600
+++ swift-pax/utils/build-script-impl 2017-01-23 13:24:10.339366996 -0600
@@ -1823,6 +1823,16 @@ function set_lldb_xcodebuild_options() {
@@ -1823,6 +1823,17 @@ function set_lldb_xcodebuild_options() {
fi
}
+## XXX: Taken from nixpkgs /pkgs/stdenv/generic/setup.sh
+isELF() {
+ local fn="$1"
+ local fd
+ local magic
+ exec {fd}< "$fn"
+ read -n 4 -u $fd magic

View File

@ -194,6 +194,7 @@ _addRpathPrefix() {
# Return success if the specified file is an ELF object.
isELF() {
local fn="$1"
local fd
local magic
exec {fd}< "$fn"
read -n 4 -u $fd magic
@ -205,6 +206,7 @@ isELF() {
# "#!").
isScript() {
local fn="$1"
local fd
local magic
if ! [ -x /bin/sh ]; then return 0; fi
exec {fd}< "$fn"