From 390260c6a689912dbf4c9d41fe36418c44b1d89a Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 30 Dec 2021 21:49:20 +0100 Subject: [PATCH] Resolve binary realpath to make sure symlinking bin proxies works, refs jakzal/phpqa#336 --- src/Composer/Installer/BinaryInstaller.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Composer/Installer/BinaryInstaller.php b/src/Composer/Installer/BinaryInstaller.php index 652b58ff1..b7b2b40ab 100644 --- a/src/Composer/Installer/BinaryInstaller.php +++ b/src/Composer/Installer/BinaryInstaller.php @@ -392,7 +392,13 @@ PROXY; return << /dev/null; cd $binDir && pwd) +self=\$(realpath \$0) +if [ -z "\$self" ] +then + self="\$0" +fi + +dir=\$(cd "\${self%[/\\\\]*}" > /dev/null; cd $binDir && pwd) if [ -d /proc/cygdrive ]; then case \$(which php) in @@ -403,7 +409,7 @@ if [ -d /proc/cygdrive ]; then esac fi -export COMPOSER_BIN_DIR=\$(cd "\${0%[/\\\\]*}" > /dev/null; pwd) +export COMPOSER_BIN_DIR=\$(cd "\${self%[/\\\\]*}" > /dev/null; pwd) "\${dir}/$binFile" "\$@"