pre-commit: Stop using legacy backticks in shell

We can repalce them with the simpler $(foo) syntax instead

https://www.shellcheck.net/wiki/SC2006

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6652>
This commit is contained in:
Jordan Petridis 2024-04-12 23:17:30 +03:00 committed by GStreamer Marge Bot
parent 2aba1c86e9
commit 7b81d081ad

View file

@ -7,11 +7,11 @@
# On some *bsd systems the binary seems to be called gnunindent, # On some *bsd systems the binary seems to be called gnunindent,
# so check for that first. # so check for that first.
version=`gnuindent --version 2>/dev/null` version=$(gnuindent --version 2>/dev/null)
if test "x$version" = "x"; then if test "x$version" = "x"; then
version=`gindent --version 2>/dev/null` version=$(gindent --version 2>/dev/null)
if test "x$version" = "x"; then if test "x$version" = "x"; then
version=`indent --version 2>/dev/null` version=$(indent --version 2>/dev/null)
if test "x$version" = "x"; then if test "x$version" = "x"; then
echo "GStreamer git pre-commit hook:" echo "GStreamer git pre-commit hook:"
echo "Did not find GNU indent, please install it before continuing." echo "Did not find GNU indent, please install it before continuing."
@ -26,7 +26,7 @@ else
INDENT=gnuindent INDENT=gnuindent
fi fi
case `$INDENT --version` in case $($INDENT --version) in
GNU*) GNU*)
;; ;;
default) default)
@ -52,11 +52,11 @@ INDENT_PARAMETERS="--braces-on-if-line \
--leave-preprocessor-space" --leave-preprocessor-space"
echo "--Checking style--" echo "--Checking style--"
for file in `git diff-index --cached --name-only HEAD --diff-filter=ACMR| grep "\.c$"` ; do for file in $(git diff-index --cached --name-only HEAD --diff-filter=ACMR| grep "\.c$") ; do
# nf is the temporary checkout. This makes sure we check against the # nf is the temporary checkout. This makes sure we check against the
# revision in the index (and not the checked out version). # revision in the index (and not the checked out version).
nf=`git checkout-index --temp ${file} | cut -f 1` nf=$(git checkout-index --temp ${file} | cut -f 1)
newfile=`mktemp /tmp/${nf}.XXXXXX` || exit 1 newfile=$(mktemp /tmp/${nf}.XXXXXX) || exit 1
$INDENT ${INDENT_PARAMETERS} \ $INDENT ${INDENT_PARAMETERS} \
$nf -o $newfile 2>> /dev/null $nf -o $newfile 2>> /dev/null
# FIXME: Call indent twice as it tends to do line-breaks # FIXME: Call indent twice as it tends to do line-breaks
@ -91,9 +91,9 @@ echo "==========================================================================
exit 1 exit 1
fi fi
csharp_files=` git diff-index --cached --name-only HEAD --diff-filter=ACMR| grep "^subprojects/gstreamer-sharp/.*cs$" ` csharp_files=$( git diff-index --cached --name-only HEAD --diff-filter=ACMR| grep "^subprojects/gstreamer-sharp/.*cs$" )
if test "x$csharp_files" != "x"; then if test "x$csharp_files" != "x"; then
version=`dotnet-format --version 2>/dev/null` version=$(dotnet-format --version 2>/dev/null)
if test "x$version" = "x"; then if test "x$version" = "x"; then
echo "GStreamer git pre-commit hook:" echo "GStreamer git pre-commit hook:"
echo "Did not find dotnet-format required to format C# files, please install it before continuing." echo "Did not find dotnet-format required to format C# files, please install it before continuing."