From 1ec19bbbbef8229c0acbea76afdca8eca8642d20 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sat, 5 Jan 2019 12:38:58 +0100 Subject: [PATCH] Optimized code and removed shellcheck errors --- administration/bash.sh | 3 ++- administration/build.sh | 12 +++++------- administration/cleanup-ignored.sh | 3 ++- administration/clear.sh | 6 +++++- administration/composer-update.sh | 6 +++++- administration/copy-configuration.sh | 6 +++--- administration/format-code.sh | 3 ++- administration/generate-coverage-report.sh | 3 ++- administration/init.sh | 14 ++++++-------- administration/load-fixtures.sh | 3 ++- administration/mysql.sh | 3 ++- administration/router.sh | 3 ++- administration/schema-update.sh | 3 ++- administration/schema-validate.sh | 3 ++- administration/shellcheck.sh | 2 +- administration/start.sh | 3 ++- administration/stop.sh | 3 ++- administration/submodule-init.sh | 4 +--- administration/submodule-sync.sh | 8 +++----- administration/test-code-format.sh | 3 ++- administration/test-everything.sh | 3 +-- administration/test.sh | 3 ++- administration/total-clean.sh | 7 ++++--- 23 files changed, 60 insertions(+), 47 deletions(-) diff --git a/administration/bash.sh b/administration/bash.sh index f1c142d..bcb1b7f 100644 --- a/administration/bash.sh +++ b/administration/bash.sh @@ -1,2 +1,3 @@ #!/bin/bash -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose exec php /bin/bash) +cd "$(dirname "$(readlink -f "${0}")")/../docker-symfony/" || exit 1 +docker-compose exec php /bin/bash diff --git a/administration/build.sh b/administration/build.sh index 326f9c7..d9a2581 100644 --- a/administration/build.sh +++ b/administration/build.sh @@ -1,8 +1,6 @@ #!/bin/bash -( -cd $(dirname $(readlink -f ${0}))/; -bash ./copy-configuration.sh -cd ../docker-symfony; -docker-compose build; -docker-compose up -d; -) +cd "$(dirname "$(readlink -f "${0}")")/" && +bash ./copy-configuration.sh && +cd ../docker-symfony && +docker-compose build && +docker-compose up -d diff --git a/administration/cleanup-ignored.sh b/administration/cleanup-ignored.sh index da1d05a..fb7cc98 100644 --- a/administration/cleanup-ignored.sh +++ b/administration/cleanup-ignored.sh @@ -1,3 +1,4 @@ #!/bin/bash echo "Untracked and ignored files will be deleted..." -(cd $(dirname $(readlink -f ${0}))/../ && git clean -fXd) +cd "$(dirname "$(readlink -f "${0}")")/../" && +git clean -fXd diff --git a/administration/clear.sh b/administration/clear.sh index f76c395..89393d7 100644 --- a/administration/clear.sh +++ b/administration/clear.sh @@ -1,2 +1,6 @@ #!/bin/bash -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose exec php php /var/www/symfony/bin/console cache:clear && docker-compose exec php php /var/www/symfony/bin/console cache:clear --env=prod) +( +cd "$(dirname "$(readlink -f "${0}")")/../docker-symfony/" && +docker-compose exec php php /var/www/symfony/bin/console cache:clear && +docker-compose exec php php /var/www/symfony/bin/console cache:clear --env=prod +) diff --git a/administration/composer-update.sh b/administration/composer-update.sh index 3c0b213..e4f9188 100644 --- a/administration/composer-update.sh +++ b/administration/composer-update.sh @@ -1,2 +1,6 @@ #!/bin/bash -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/&& docker-compose exec php composer install && docker-compose exec php composer update) +( +cd "$(dirname "$(readlink -f "${0}")")/../docker-symfony/" && +docker-compose exec php composer install && +docker-compose exec php composer update +) diff --git a/administration/copy-configuration.sh b/administration/copy-configuration.sh index 355cd98..f6285f7 100644 --- a/administration/copy-configuration.sh +++ b/administration/copy-configuration.sh @@ -1,5 +1,5 @@ #!/bin/bash # Copies the configuration files -cd $(dirname $(readlink -f ${0}))/../; -cp -v .env.dist docker-symfony/.env; -cp -v ./application/phpunit.xml.dist ./application/phpunit.xml; +cd "$(dirname "$(readlink -f "${0}")")/../" || exit 1 +cp -v .env.dist docker-symfony/.env +cp -v ./application/phpunit.xml.dist ./application/phpunit.xml diff --git a/administration/format-code.sh b/administration/format-code.sh index 811505a..309d3a2 100644 --- a/administration/format-code.sh +++ b/administration/format-code.sh @@ -1,2 +1,3 @@ #!/bin/bash -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose exec php php vendor/bin/php-cs-fixer fix .) +cd "$(dirname "$(readlink -f "${0}")")/../docker-symfony/" || exit 1 +docker-compose exec php php vendor/bin/php-cs-fixer fix . diff --git a/administration/generate-coverage-report.sh b/administration/generate-coverage-report.sh index b0d3908..860d748 100644 --- a/administration/generate-coverage-report.sh +++ b/administration/generate-coverage-report.sh @@ -1,2 +1,3 @@ #!/bin/bash -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose exec php php -d memory_limit=128M /var/www/symfony/vendor/bin/phpunit --coverage-html var/test-coverage-report) +cd "$(dirname "$(readlink -f "${0}")")/../docker-symfony/" || exit 1 +docker-compose exec php php -d memory_limit=128M /var/www/symfony/vendor/bin/phpunit --coverage-html var/test-coverage-report diff --git a/administration/init.sh b/administration/init.sh index 2540ca8..f0acd26 100644 --- a/administration/init.sh +++ b/administration/init.sh @@ -1,9 +1,7 @@ #!/bin/bash -( - cd $(dirname $(readlink -f ${0})); - bash ./submodule-init.sh - bash ./build.sh - bash ./composer-update.sh - bash ./schema-update.sh - bash ./load-fixtures.sh -) +cd "$(dirname "$(readlink -f "${0}")")" && +bash ./submodule-init.sh && +bash ./build.sh && +bash ./composer-update.sh && +bash ./schema-update.sh && +bash ./load-fixtures.sh diff --git a/administration/load-fixtures.sh b/administration/load-fixtures.sh index 2eeb6fd..6770737 100644 --- a/administration/load-fixtures.sh +++ b/administration/load-fixtures.sh @@ -1,2 +1,3 @@ #!/bin/bash -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose exec php php bin/console doctrine:fixtures:load -n) +cd "$(dirname "$(readlink -f "${0}")")/../docker-symfony/" || exit 1 +docker-compose exec php php bin/console doctrine:fixtures:load -n diff --git a/administration/mysql.sh b/administration/mysql.sh index ba134b6..e64fd06 100644 --- a/administration/mysql.sh +++ b/administration/mysql.sh @@ -1,2 +1,3 @@ #!/bin/bash -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose exec db mysql -proot -u root) +cd "$(dirname "$(readlink -f "${0}")")/../docker-symfony/" || exit 1 +docker-compose exec db mysql -proot -u root diff --git a/administration/router.sh b/administration/router.sh index 2aa9224..fb2ce87 100644 --- a/administration/router.sh +++ b/administration/router.sh @@ -1,2 +1,3 @@ #!/bin/bash -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose exec php php bin/console debug:router); +cd "$(dirname "$(readlink -f "${0}")")/../docker-symfony/" || exit 1 +docker-compose exec php php bin/console debug:router diff --git a/administration/schema-update.sh b/administration/schema-update.sh index 2e56831..0d09f1c 100644 --- a/administration/schema-update.sh +++ b/administration/schema-update.sh @@ -1,2 +1,3 @@ #!/bin/bash -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose exec php php bin/console doctrine:schema:update --force) +cd "$(dirname "$(readlink -f "${0}")")/../docker-symfony/" || exit 1 +docker-compose exec php php bin/console doctrine:schema:update --force diff --git a/administration/schema-validate.sh b/administration/schema-validate.sh index a2fd823..3e2f456 100644 --- a/administration/schema-validate.sh +++ b/administration/schema-validate.sh @@ -1,2 +1,3 @@ #!/bin/bash -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose exec php bin/console doctrine:schema:validate) +cd "$(dirname "$(readlink -f "${0}")")/../docker-symfony/" && +docker-compose exec php bin/console doctrine:schema:validate diff --git a/administration/shellcheck.sh b/administration/shellcheck.sh index 877500a..5aec32c 100644 --- a/administration/shellcheck.sh +++ b/administration/shellcheck.sh @@ -1,3 +1,3 @@ #!/bin/bash -cd $(dirname $(readlink -f ${0}))/; +cd "$(dirname "$(readlink -f "${0}")")/" && shellcheck ./*.sh diff --git a/administration/start.sh b/administration/start.sh index 9cc187b..30c8c05 100644 --- a/administration/start.sh +++ b/administration/start.sh @@ -1,2 +1,3 @@ #!/bin/bash -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose up -d) +cd "$(dirname "$(readlink -f "${0}")")/../docker-symfony/" && +docker-compose up -d diff --git a/administration/stop.sh b/administration/stop.sh index 8d610a5..d7f3439 100644 --- a/administration/stop.sh +++ b/administration/stop.sh @@ -1,2 +1,3 @@ #!/bin/bash -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose stop) +cd "$(dirname "$(readlink -f "${0}")")/../docker-symfony/" && +docker-compose stop diff --git a/administration/submodule-init.sh b/administration/submodule-init.sh index 06bc520..fb8c369 100644 --- a/administration/submodule-init.sh +++ b/administration/submodule-init.sh @@ -1,5 +1,3 @@ #!/bin/bash -( -cd $(dirname $(readlink -f ${0}))/../; +cd "$(dirname "$(readlink -f "${0}")")/../" && git submodule update --init --recursive -) diff --git a/administration/submodule-sync.sh b/administration/submodule-sync.sh index 1a0bc15..0ecf7b5 100644 --- a/administration/submodule-sync.sh +++ b/administration/submodule-sync.sh @@ -1,6 +1,4 @@ #!/bin/bash -( - cd $(dirname $(readlink -f ${0}))/../; - git submodule sync; - git submodule foreach git pull origin master; -) +cd "$(dirname "$(readlink -f "${0}")")/../" && +git submodule sync && +git submodule foreach git pull origin master diff --git a/administration/test-code-format.sh b/administration/test-code-format.sh index 8716961..f06173c 100644 --- a/administration/test-code-format.sh +++ b/administration/test-code-format.sh @@ -1,2 +1,3 @@ #!/bin/bash -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose exec php php ./vendor/bin/php-cs-fixer fix -v --diff --dry-run ./src) +cd "$(dirname "$(readlink -f "${0}")")/../docker-symfony/" || exit 1 +docker-compose exec php php ./vendor/bin/php-cs-fixer fix -v --diff --dry-run ./src diff --git a/administration/test-everything.sh b/administration/test-everything.sh index 0f3a2a9..27e2630 100644 --- a/administration/test-everything.sh +++ b/administration/test-everything.sh @@ -1,7 +1,6 @@ #!/bin/bash -(cd $(dirname $(readlink -f ${0}))/ && +cd "$(dirname "$(readlink -f "${0}")")/" && bash ./clear.sh && bash ./schema-validate.sh && bash ./test.sh && bash ./test-code-format.sh -) diff --git a/administration/test.sh b/administration/test.sh index 831c5fa..c63338a 100644 --- a/administration/test.sh +++ b/administration/test.sh @@ -1,2 +1,3 @@ #!/bin/bash -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose exec php php -d memory_limit=128M /var/www/symfony/vendor/bin/phpunit) +cd "$(dirname "$(readlink -f "${0}")")/../docker-symfony/" && +docker-compose exec php php -d memory_limit=128M /var/www/symfony/vendor/bin/phpunit diff --git a/administration/total-clean.sh b/administration/total-clean.sh index 47c2af2..fdfc5d2 100644 --- a/administration/total-clean.sh +++ b/administration/total-clean.sh @@ -1,4 +1,5 @@ #!/bin/sh -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose exec php rm -vr var) -(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose exec php rm -vr vendor ) -(cd $(dirname $(readlink -f ${0}))/ && bash cleanup-ignored.sh) +cd "$(dirname "$(readlink -f "${0}")")/../docker-symfony/" || exit 1 +docker-compose exec php rm -vr var +docker-compose exec php rm -vr vendor +cd "$(dirname "$(readlink -f "${0}")")/" && bash cleanup-ignored.sh