Não é possível ler a variável da entrada do usuário no bash

1

Eu tento executar o script do meu amigo e recebo este erro quando tento inserir alguma variável:

: bad variable nameead: reload
: not foundsh: 10: bin/reload.sh: 
bin/reload.sh: 11: bin/reload.sh: Syntax error: word unexpected (expecting "in")

Onde está o problema? Aqui está o código do 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
    
por nowiko 10.11.2014 / 09:25

1 resposta

2

Eu resolvo esse problema. Foi muito simples. Eu preciso alterar as extremidades das seqüências de caracteres para o formato Unix / Linux no meu arquivo .sh em vez de o Windows terminar.

    
por nowiko 10.11.2014 / 13:49