From 55b06705d54e8d43f860219377ef3455e66c4ed7 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Wed, 14 Apr 2021 15:50:19 +0100 Subject: [PATCH] [SCRIPTS] pre-commit now has variables double quoted --- bin/pre-commit | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/pre-commit b/bin/pre-commit index dae2bc89b9..833749ce9a 100755 --- a/bin/pre-commit +++ b/bin/pre-commit @@ -1,4 +1,3 @@ - #!/usr/bin/env bash root="$(git rev-parse --show-toplevel)" @@ -10,12 +9,14 @@ echo "Running php-cs-fixer on edited files" for staged in ${staged_files}; do # work only with existing files - if [[ -f ${staged} && ${staged} == *.php ]]; then + if [ -f "${staged}" ] && [[ "${staged}" = *.php ]] + then # use php-cs-fixer and get flag of correction "${root}/bin/php-cs-fixer" -q fix "${staged}" # if php-cs-fixer fix works, it returns 0 - if [[ $? -eq 0 ]]; then + if [ "$?" -eq 0 ] + then git add "${staged}" # execute git add directly fi fi