From d53920a5beb19541ce61107844ab2f5e27c19b44 Mon Sep 17 00:00:00 2001 From: Albert Safin Date: Thu, 19 Sep 2019 09:48:15 +0000 Subject: [PATCH] setup.sh: avoid subshells: mapOffset --- pkgs/stdenv/generic/setup.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 60067a4051de..7e7f8739845b 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -403,6 +403,7 @@ findInputs() { # The current package's host and target offset together # provide a <=-preserving homomorphism from the relative # offsets to current offset + local -i mapOffsetResult function mapOffset() { local -ri inputOffset="$1" if (( "$inputOffset" <= 0 )); then @@ -410,7 +411,7 @@ findInputs() { else local -ri outputOffset="$inputOffset - 1 + $targetOffset" fi - echo "$outputOffset" + mapOffsetResult="$outputOffset" } # Host offset relative to that of the package whose immediate @@ -422,8 +423,8 @@ findInputs() { # Host offset relative to the package currently being # built---as absolute an offset as will be used. - local -i hostOffsetNext - hostOffsetNext="$(mapOffset relHostOffset)" + mapOffset relHostOffset + local -i hostOffsetNext="$mapOffsetResult" # Ensure we're in bounds relative to the package currently # being built. @@ -441,8 +442,8 @@ findInputs() { # Target offset relative to the package currently being # built. - local -i targetOffsetNext - targetOffsetNext="$(mapOffset relTargetOffset)" + mapOffset relTargetOffset + local -i targetOffsetNext="$mapOffsetResult" # Once again, ensure we're in bounds relative to the # package currently being built.