From 6dea58c9f39a1af3dbee8d014cf042aaf5661d25 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 7 Jan 2022 14:28:53 +0100 Subject: [PATCH] Add support for sourcing binaries despite the bin proxy being present Fixes https://github.com/composer/composer/issues/10389#issuecomment-1007372740 --- src/Composer/Installer/BinaryInstaller.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Composer/Installer/BinaryInstaller.php b/src/Composer/Installer/BinaryInstaller.php index ec0fbd337..a67976cd0 100644 --- a/src/Composer/Installer/BinaryInstaller.php +++ b/src/Composer/Installer/BinaryInstaller.php @@ -397,9 +397,16 @@ PROXY; return << /dev/null) +# Support bash to support `source` with fallback on $0 if this does not run with bash +# https://stackoverflow.com/a/35006505/6512 +selfArg="\$BASH_SOURCE" +if [ -z "\$selfArg" ]; then + selfArg="\$0" +fi + +self=\$(realpath \$selfArg 2> /dev/null) if [ -z "\$self" ]; then - self="\$0" + self="\$selfArg" fi dir=\$(cd "\${self%[/\\\\]*}" > /dev/null; cd $binDir && pwd)