Scroll
Drush mostra errore: Supporta bash per utilizzare 'source' con fallback su $0 se questo non viene eseguito con bash
Ho un numero enorme di configurazioni e solitamente eseguo l’import delle config con php -d memory_limit=-1
(disabilita il limite di memoria per PHP):
php -d memory_limit=-1 ./vendor/bin/drush config-import -y
Ma questa volta ho ricevuto un errore:
# Supporta bash per usare `source` con fallback su $0 se questo non viene eseguito con 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="$selfArg"
fi
dir=$(cd "${self%[/\\]*}" > /dev/null; cd ../drush/drush && pwd)
if [ -d /proc/cygdrive ]; then
case $(which php) in
$(readlink -n /proc/cygdrive)/*)
# Siamo in Cygwin usando php di Windows, quindi il percorso deve essere tradotto
dir=$(cygpath -m "$dir");
;;
esac
fi
export COMPOSER_RUNTIME_BIN_DIR="$(cd "${self%[/\\]*}" > /dev/null; pwd)"
# Se bash sta facendo il source di questo file, dobbiamo fare il source anche del target
bashSource="$BASH_SOURCE"
if [ -n "$bashSource" ]; then
if [ "$bashSource" != "$0" ]; then
source "${dir}/drush" "$@"
return
fi
fi
"${dir}/drush" "$@"
Puoi evitare questo errore se invii memory_limit=-1
come php-options
:
./vendor/bin/drush --php-options='-d memory_limit=-1' config-import -y
Perché php -d memory_limit=-1 vendor/bin/drush …
ora esplode
Forzando il file attraverso php
, stai dicendo all’interprete PHP di analizzare uno script bash:
php -d memory_limit=-1 ./vendor/bin/drush status
PHP prova diligentemente a eseguire la prima riga non-PHP (# Support bash …
) e muore immediatamente, stampando a schermo il sorgente del wrapper. Questo è esattamente l’output che hai incollato. La modifica è stata introdotta in Drush 13.3 ed è discussa nell’issue upstream “Running drush as php script fails after updating from 13.2.0”.