nixpkgs/pkgs/build-support/emacs/wrapper.sh
Daniel Nagy 0f316e5553
emacsWrapper: fix mishandling of empty package list
The native compiler of emacs does not handle empty files well.

This arose in https://github.com/NixOS/nixpkgs/pull/168954 .
2022-04-19 21:12:45 +02:00

47 lines
1,009 B
Bash

#!@bash@
IFS=:
newLoadPath=()
newNativeLoadPath=()
added=
if [[ -n $EMACSLOADPATH ]]
then
while read -rd: entry
do
if [[ -z $entry && -z $added ]]
then
newLoadPath+=(@wrapperSiteLisp@)
added=1
fi
newLoadPath+=("$entry")
done <<< "$EMACSLOADPATH:"
else
newLoadPath+=(@wrapperSiteLisp@)
newLoadPath+=("")
fi
if [[ -n $EMACSNATIVELOADPATH ]]
then
while read -rd: entry
do
if [[ -z $entry && -z $added ]]
then
newNativeLoadPath+=(@wrapperSiteLispNative@)
added=1
fi
newNativeLoadPath+=("$entry")
done <<< "$EMACSNATIVELOADPATH:"
else
newNativeLoadPath+=(@wrapperSiteLispNative@)
newNativeLoadPath+=("")
fi
export EMACSLOADPATH="${newLoadPath[*]}"
export emacsWithPackages_siteLisp=@wrapperSiteLisp@
export EMACSNATIVELOADPATH="${newNativeLoadPath[*]}"
export emacsWithPackages_siteLispNative=@wrapperSiteLispNative@
exec @prog@ @autoloadExpression@ "$@"