]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
bin: Run scripts through shellcheck
authorStephen Finucane <stephen@that.guru>
Fri, 2 Dec 2016 10:36:58 +0000 (10:36 +0000)
committerStephen Finucane <stephen@that.guru>
Mon, 6 Feb 2017 18:58:01 +0000 (18:58 +0000)
This mostly results in the addition of quotes to prevent globbing.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
patchwork/bin/parsemail-batch.sh
patchwork/bin/parsemail.sh

index c94655bf459096a0b5799ad459f7e5f88657d625..bee047e3cc3cf4c197219970df24765f0a783e94 100755 (executable)
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-PATCHWORK_BINDIR=`dirname $0`
+PATCHWORK_BINDIR=$(dirname "$0")
 
-if [ $# -lt 1 ]
-then
+if [ $# -lt 1 ]; then
     echo "usage: $0 <dir> [options]" >&2
     exit 1
 fi
@@ -31,17 +30,15 @@ mail_dir="$1"
 
 echo "dir: $mail_dir"
 
-if [ ! -d "$mail_dir" ]
-then
+if [ ! -d "$mail_dir" ]; then
     echo "$mail_dir should be a directory"? >&2
     exit 1
 fi
 
 shift
 
-ls -1rt "$mail_dir" |
-while read line;
-do
-    echo $line
-    $PATCHWORK_BINDIR/parsemail.sh $@ < "$mail_dir/$line"
+find "$mail_dir" -maxdepth 1 |
+while read -r line; do
+    echo "$line"
+    "$PATCHWORK_BINDIR/parsemail.sh" "$@" < "$mail_dir/$line"
 done
index 1ddad7f0d233b4a47a761edd4f19c5b4e69bbbb4..a742f60e54324ab8cf99a33dbd1560ed543def04 100755 (executable)
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-BIN_DIR=`dirname $0`
-PATCHWORK_BASE=`readlink -e $BIN_DIR/../..`
+BIN_DIR=$(dirname "$0")
+PATCHWORK_BASE=$(readlink -e "$BIN_DIR/../..")
 
-if [ -z $PW_PYTHON ]; then
+if [ -z "$PW_PYTHON" ]; then
     PW_PYTHON=python2
 fi
 
-if [ -z $DJANGO_SETTINGS_MODULE ]; then
+if [ -z "$DJANGO_SETTINGS_MODULE" ]; then
     DJANGO_SETTINGS_MODULE=patchwork.settings.production
 fi
 
-PYTHONPATH="$PATCHWORK_BASE":"$PATCHWORK_BASE/lib/python:$PYTHONPATH" \
+PYTHONPATH="${PATCHWORK_BASE}:${PATCHWORK_BASE}/lib/python:$PYTHONPATH" \
     DJANGO_SETTINGS_MODULE="$DJANGO_SETTINGS_MODULE" \
-    $PW_PYTHON "$PATCHWORK_BASE/manage.py" parsemail $@
+    "$PW_PYTHON" "$PATCHWORK_BASE/manage.py" parsemail "$@"
 
 # NOTE(stephenfin): We must return 0 here. When parsemail is used as a
 # delivery command from a mail server like postfix (as it is intended