J'essaie d'exécuter le script de mon ami et j'obtiens cette erreur lorsque j'essaie de saisir une variable:
: bad variable nameead: reload
: not foundsh: 10: bin/reload.sh:
bin/reload.sh: 11: bin/reload.sh: Syntax error: Word unexpected (expecting "in")
Où est le problème? Voici le code du script sh:
#!/bin/bash
echo ""
echo "Выберите необходимое действие:"
echo " 1 - reload."
echo " 2 - db."
echo " 3 - tests."
echo " 0 - exit."
read reload
case $reload in
1)
echo "reload."
php composer.phar update
php vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
rm -rf app/cache/*
rm -rf app/logs/*
touch app/logs/error.log
APACHEUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data' | grep -v root | head -1 | cut -d\ -f1`
mkdir -p web/upload/media
rm -rf web/upload/media/*
rm -rf web/upload/dream/*
rm -rf web/upload/tmp/*
setfacl -R -m u:"$APACHEUSER":rwX -m u:`whoami`:rwX app/cache app/logs web/upload
setfacl -dR -m u:"$APACHEUSER":rwX -m u:`whoami`:rwX app/cache app/logs web/upload
php app/console doctrine:database:drop --force
php app/console doctrine:database:create
php app/console doctrine:schema:update --force
php app/console cache:clear
php app/console doctrine:fixtures:load --no-interaction
php app/console assets:install --symlink
php app/console assetic:dump
php app/console cache:clear
;;
2)
echo "reload db."
php app/console doctrine:database:drop --force
php app/console doctrine:database:create
php app/console doctrine:schema:update --force
php app/console doctrine:fixtures:load --no-interaction
php app/console assets:install --symlink
php app/console assetic:dump
php app/console cache:clear
;;
3)
echo ""
echo "tests:"
echo " 1 - Запуск всех тестов."
echo " 2 - Запуск юнит тестов."
echo " 0 - Выход."
read testing
case $testing in
1)
echo "Запуск всех тестов."
php app/console doctrine:database:drop --force
php app/console doctrine:database:create
php app/console doctrine:schema:update --force
php app/console cache:clear
php app/console doctrine:fixtures:load --no-interaction
php app/console cache:clear
sh bin/tests.sh
;;
2)
echo "Запуск юнит тестов."
php app/console doctrine:database:drop --force
php app/console doctrine:database:create
php app/console doctrine:schema:update --force
php app/console cache:clear
php app/console doctrine:fixtures:load --no-interaction
php app/console cache:clear
bin/phpunit -c app
;;
0)
exit 0
;;
*)
echo "Введите правильное действие!"
sh bin/reload.sh
esac
;;
0)
exit 0
;;
*)
echo "Введите правильное действие!"
sh bin/reload.sh
esac
Je résous ce problème. C'était très simple. Je dois changer les extrémités des chaînes au format Unix/Linux dans mon fichier .sh au lieu des extrémités Windows.