]> granicus.if.org Git - transmission/commitdiff
Refactor shell scripts with syntax and styling fixes
authorPeter Dave Hello <hsu@peterdavehello.org>
Tue, 15 Jan 2019 19:22:29 +0000 (03:22 +0800)
committerPeter Dave Hello <hsu@peterdavehello.org>
Tue, 15 Jan 2019 19:22:29 +0000 (03:22 +0800)
autogen.sh
daemon/my-valgrind.sh
extras/send-email-when-torrent-done.sh
gtk/my-valgrind.sh
libtransmission/fail.sh
qt/my-valgrind.sh
update-version-h.sh

index 385f156257835e5fe2a5b78117bac0083b40408b..f63e5d7d8b2d7a8fa90205341871cc1a03be344d 100755 (executable)
@@ -1,31 +1,28 @@
 #!/bin/sh
-srcdir=`dirname $0`
+srcdir=$(dirname "$0")
 test -z "$srcdir" && srcdir=.
 
-ORIGDIR=`pwd`
-cd "$srcdir"
+ORIGDIR=$(pwd)
+cd "$srcdir" || exit 1
 PROJECT=Transmission
 
 GETTEXTIZE="glib-gettextize"
 $GETTEXTIZE --version < /dev/null > /dev/null 2>&1
 if test $? -ne 0; then
-    GETTEXTIZE=""
+  GETTEXTIZE=""
 fi
 
 LIBTOOLIZE=libtoolize
-if libtoolize --help >/dev/null 2>&1
-then
+if libtoolize --help > /dev/null 2>&1; then
   :
-elif glibtoolize --help >/dev/null 2>&1
-then
+elif glibtoolize --help > /dev/null 2>&1; then
   LIBTOOLIZE=glibtoolize
 fi
 export LIBTOOLIZE
 
 ./update-version-h.sh
 
-autoreconf -fi || exit 1;
-
+autoreconf -fi || exit 1
 
 if test "$GETTEXTIZE"; then
   echo "Creating aclocal.m4 ..."
@@ -41,10 +38,9 @@ fi
 cd "$ORIGDIR" || exit $?
 
 if test -z "$AUTOGEN_SUBDIR_MODE"; then
-       echo Running $srcdir/configure "$@"
-        $srcdir/configure "$@"
+  echo Running $srcdir/configure "$@"
+  $srcdir/configure "$@"
 
-        echo 
-        echo "Now type 'make' to compile $PROJECT."
+  echo
+  echo "Now type 'make' to compile $PROJECT."
 fi
-
index 7db09f934f346cf6a4d5aa66bd96b3da1a7c3dcf..52c27f4aa793d72bee6ccd457a8cb3ad6a7bf818 100755 (executable)
@@ -1,4 +1,4 @@
-#/bin/sh
+#!/bin/sh
 export G_SLICE=always-malloc
 export G_DEBUG=gc-friendly
 export GLIBCXX_FORCE_NEW=1
index ff4416486ba86b8cb79569e8dc6ac0ba3dfacb5b..79d6d8fa2f638f5ff62a0cd94f8bac76fe4ecf24 100755 (executable)
@@ -47,7 +47,7 @@ SMTP_SERVER=your.smtp.server
 
 SUBJECT="Torrent Done!"
 FROM_ADDR="transmission@localhost.localdomain"
-TMPFILE=`mktemp -t transmission.XXXXXXXXXX`
-echo "Transmission finished downloading \"$TR_TORRENT_NAME\" on $TR_TIME_LOCALTIME" >$TMPFILE
-$NAIL -v -S from="$FROM_ADDR" -S smtp -s "$SUBJECT" -S smtp=$SMTP_SERVER "$TO_ADDR" < $TMPFILE
-rm $TMPFILE
+TMPFILE=$(mktemp -t transmission.XXXXXXXXXX)
+echo "Transmission finished downloading \"$TR_TORRENT_NAME\" on $TR_TIME_LOCALTIME" > "$TMPFILE"
+$NAIL -v -S from="$FROM_ADDR" -S smtp -s "$SUBJECT" -S smtp=$SMTP_SERVER "$TO_ADDR" < "$TMPFILE"
+rm "$TMPFILE"
index 87d960b8ee15c8636f479e599bc2126bcade597f..76683ae5b1551d8b88c564650651afea2849bbbb 100755 (executable)
@@ -1,4 +1,4 @@
-#/bin/sh
+#!/bin/sh
 export G_SLICE=always-malloc
 export G_DEBUG=gc-friendly
 export GLIBCXX_FORCE_NEW=1
index 22a6171ec267e4b4d4bf9fec004ed4dcd7bc2162..d0beda970e503ebb27d3049e0762e49c46e60043 100755 (executable)
@@ -1,7 +1,8 @@
+#!/bin/sh
 err=0
 count=0
 while [ $err -eq 0 ]; do
-  count=$((count+1))
+  count=$((count + 1))
   echo starting run number $count
   make check
   err=$?
index c3e14cd649877f0b527b10c24179658a5d01e217..79803ee4141500fa731cae61f12282fb05011396 100755 (executable)
@@ -1,4 +1,4 @@
-#/bin/sh
+#!/bin/sh
 #valgrind --tool=cachegrind ./transmission-qt 2>&1 | tee runlog
 #valgrind --tool=massif --threshold=0.2 ./transmission-qt 2>&1 | tee runlog
 valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=16 --log-file=x-valgrind --show-reachable=no ./transmission-qt 2>&1 | tee runlog
index b1e326b4fb2622922903a55e0d864a8779d09764..386e4bbd9c687f85c98f4f2bbd0beb940a85ffba 100755 (executable)
@@ -2,47 +2,44 @@
 
 # Generate files to be included: only overwrite them if changed so make
 # won't rebuild everything unless necessary
-replace_if_differs ()
-{
-    if cmp $1 $2 > /dev/null 2>&1; then
-      rm -f $1
-    else
-      mv -f $1 $2
-    fi
+replace_if_differs() {
+  if cmp "$1" "$2" > /dev/null 2>&1; then
+    rm -f "$1"
+  else
+    mv -f "$1" "$2"
+  fi
 }
 
 echo "creating libtransmission/version.h"
 
-user_agent_prefix=`grep m4_define configure.ac | sed "s/[][)(]/,/g" | grep user_agent_prefix  | cut -d , -f 6`
+user_agent_prefix=$(grep m4_define configure.ac | sed "s/[][)(]/,/g" | grep user_agent_prefix | cut -d , -f 6)
 
-peer_id_prefix=`grep m4_define configure.ac | sed "s/[][)(]/,/g" | grep peer_id_prefix  | cut -d , -f 6`
+peer_id_prefix=$(grep m4_define configure.ac | sed "s/[][)(]/,/g" | grep peer_id_prefix | cut -d , -f 6)
 
-major_version=`echo ${user_agent_prefix} | awk -F . '{print $1}'`
-minor_version=`echo ${user_agent_prefix} | awk -F . '{print $2 + 0}'`
+major_version=$(echo "${user_agent_prefix}" | awk -F . '{print $1}')
+minor_version=$(echo "${user_agent_prefix}" | awk -F . '{print $2 + 0}')
 
 vcs_revision=
 vcs_revision_file=REVISION
 
-if [ -n "$JENKINS_URL" -a -n "$GIT_COMMIT" ]; then
-    vcs_revision=$GIT_COMMIT
-elif [ -n "$TEAMCITY_PROJECT_NAME" -a -n "$BUILD_VCS_NUMBER" ]; then
-    vcs_revision=$BUILD_VCS_NUMBER
-elif [ -d ".git" ] && type git >/dev/null 2>&1; then
-    vcs_revision=`git rev-list --max-count=1 HEAD`
+if [ -n "$JENKINS_URL" ] && [ -n "$GIT_COMMIT" ]; then
+  vcs_revision=$GIT_COMMIT
+elif [ -n "$TEAMCITY_PROJECT_NAME" ] && [ -n "$BUILD_VCS_NUMBER" ]; then
+  vcs_revision=$BUILD_VCS_NUMBER
+elif [ -d ".git" ] && type git > /dev/null 2>&1; then
+  vcs_revision=$(git rev-list --max-count=1 HEAD)
 elif [ -f "$vcs_revision_file" ]; then
-    vcs_revision=`cat "$vcs_revision_file"`
+  vcs_revision=$(cat "$vcs_revision_file")
 fi
 
-vcs_revision=`echo $vcs_revision`
-
 if [ -n "$vcs_revision" ]; then
-    [ -f "$vcs_revision_file" ] && [ "`cat "$vcs_revision_file"`" = "$vcs_revision" ] || echo "$vcs_revision" > "$vcs_revision_file"
+  [ -f "$vcs_revision_file" ] && [ "$(cat "$vcs_revision_file")" = "$vcs_revision" ] || echo "$vcs_revision" > "$vcs_revision_file"
 else
-    vcs_revision=0
-    rm -f "$vcs_revision_file"
+  vcs_revision=0
+  rm -f "$vcs_revision_file"
 fi
 
-vcs_revision=`echo $vcs_revision | head -c10`
+vcs_revision=$(echo $vcs_revision | head -c10)
 
 cat > libtransmission/version.h.new << EOF
 #pragma once
@@ -61,9 +58,9 @@ EOF
 
 # Add a release definition
 case "${peer_id_prefix}" in
-    *X-) echo '#define TR_BETA_RELEASE           1' ;;
-    *Z-) echo '#define TR_NIGHTLY_RELEASE        1' ;;
-    *)   echo '#define TR_STABLE_RELEASE         1' ;;
+  *X-) echo '#define TR_BETA_RELEASE           1' ;;
+  *Z-) echo '#define TR_NIGHTLY_RELEASE        1' ;;
+  *)   echo '#define TR_STABLE_RELEASE         1' ;;
 esac >> "libtransmission/version.h.new"
 
 replace_if_differs libtransmission/version.h.new libtransmission/version.h