[fractal/fractal-next] Remove bashism from git pre-commit hook



commit 19f9a911d86e470552da91d5d59a25fb33ea8ce5
Author: Giuseppe De Palma <depalma gsp gmail com>
Date:   Tue Jun 22 07:03:29 2021 +0000

    Remove bashism from git pre-commit hook

 hooks/pre-commit.hook | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/hooks/pre-commit.hook b/hooks/pre-commit.hook
index 363b8d5b..452a415a 100755
--- a/hooks/pre-commit.hook
+++ b/hooks/pre-commit.hook
@@ -17,7 +17,7 @@ install_rustfmt() {
     fi
 }
 
-if ! which cargo &> /dev/null || ! cargo fmt --help &> /dev/null; then
+if ! which cargo >/dev/null 2>&1 || ! cargo fmt --help >/dev/null 2>&1; then
     echo "Unable to check Fractal’s code style, because rustfmt could not be run."
 
     if [ ! -t 1 ]; then
@@ -31,15 +31,18 @@ if ! which cargo &> /dev/null || ! cargo fmt --help &> /dev/null; then
     echo "n: Don't install rustfmt and perform the commit"
     echo "Q: Don't install rustfmt and abort the commit"
 
-    while true; do
-        read -p "Install rustfmt via rustup? [y/n/Q]: " yn
+    echo ""
+    while true
+    do
+        echo -n "Install rustfmt via rustup? [y/n/Q]: "; read yn < /dev/tty
         case $yn in
             [Yy]* ) install_rustfmt; break;;
             [Nn]* ) echo "Performing commit."; exit 0;;
-            [Qq]* | "" ) echo "Aborting commit."; exit -1;;
+            [Qq]* | "" ) echo "Aborting commit."; exit -1 >/dev/null 2>&1;;
             * ) echo "Invalid input";;
         esac
     done
+
 fi
 
 echo "--Checking style--"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]