* Don't use the "replace-literal" command in stdenv; instead use
bash's pattern replacement feature. "replace-literal" is an
uncommon command so it was a headache during the bootstrap.
···16161717mkdir $out
18181919-# Can't use substitute() here, because replace may not have been
2020-# built yet (in the bootstrap).
2119sed \
2220 -e "s^@preHook@^$_preHook^g" \
2321 -e "s^@postHook@^$_postHook^g" \
+9-13
pkgs/stdenv/generic/setup.sh
···315315 local output="$2"
316316317317 local -a params=("$@")
318318- local -a args=()
319318320319 local n p pattern replacement varName
320320+321321+ local content="$(cat $input)"
321322322323 for ((n = 2; n < ${#params[*]}; n += 1)); do
323324 p=${params[$n]}
324325325325- if test "$p" = "--replace"; then
326326+ if [ "$p" = --replace ]; then
326327 pattern="${params[$((n + 1))]}"
327328 replacement="${params[$((n + 2))]}"
328329 n=$((n + 2))
329330 fi
330331331331- if test "$p" = "--subst-var"; then
332332+ if [ "$p" = --subst-var ]; then
332333 varName="${params[$((n + 1))]}"
333334 pattern="@$varName@"
334335 replacement="${!varName}"
335336 n=$((n + 1))
336337 fi
337338338338- if test "$p" = "--subst-var-by"; then
339339+ if [ "$p" = --subst-var-by ]; then
339340 pattern="@${params[$((n + 1))]}@"
340341 replacement="${params[$((n + 2))]}"
341342 n=$((n + 2))
342343 fi
343344344344- if test ${#args[@]} != 0; then
345345- args[${#args[@]}]="-a"
346346- fi
347347- args[${#args[@]}]="$pattern"
348348- args[${#args[@]}]="$replacement"
345345+ content="${content//"$pattern"/$replacement}"
349346 done
350347351351- replace-literal -e -s -- "${args[@]}" < "$input" > "$output".tmp
352352- if test -x "$output"; then
353353- chmod +x "$output".tmp
354354- fi
348348+ # !!! This doesn't work properly if $content is "-n".
349349+ echo -n "$content" > "$output".tmp
350350+ if [ -x "$output" ]; then chmod +x "$output".tmp; fi
355351 mv -f "$output".tmp "$output"
356352}
357353