-
-
Save anton-matosov/e0bb91f4c85f764f7492fcec53e5a658 to your computer and use it in GitHub Desktop.
A script used for modifying the ghc's scripts installed by stack, so that they use a local sh executable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stackargs=$@ | |
shbin="$(which sh)" | |
if [ -z "$shbin" ] || [[ "$shbin" =~ "not found" ]]; then | |
echo "Couldn't find sh, exiting." | |
exit 1 | |
else | |
echo "Found sh: $shbin" | |
fi | |
compilerbin=$(stack path $stackargs | grep compiler-bin | cut -d' ' -f2) | |
echo "Current project's compiler-bin: $compilerbin" | |
cd $compilerbin | |
echo "Modifying the scripts in $compilerbin.." | |
sedexpr="s@$shbin@$compilerbin/sh@" | |
for file in $(ls) | |
do | |
# Modify every $file that is neither a symlink nor a binary file | |
if [[ ! -L "$file" ]] && [[ ! "$(file -b --mime $file)" =~ "binary" ]]; then | |
sed -i bak "$sedexpr" $file | |
fi | |
done | |
echo "Copying $shbin to $compilerbin.." | |
cp $shbin $compilerbin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment