From 2d142b2c0a2710a0641966c86edbc9546498b7e2 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 2 Dec 2016 10:36:58 +0000 Subject: [PATCH] bin: Run scripts through shellcheck This mostly results in the addition of quotes to prevent globbing. Signed-off-by: Stephen Finucane Reviewed-by: Daniel Axtens --- patchwork/bin/parsemail-batch.sh | 17 +++++++---------- patchwork/bin/parsemail.sh | 12 ++++++------ 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/patchwork/bin/parsemail-batch.sh b/patchwork/bin/parsemail-batch.sh index c94655bf..bee047e3 100755 --- a/patchwork/bin/parsemail-batch.sh +++ b/patchwork/bin/parsemail-batch.sh @@ -19,10 +19,9 @@ # 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 [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 diff --git a/patchwork/bin/parsemail.sh b/patchwork/bin/parsemail.sh index 1ddad7f0..a742f60e 100755 --- a/patchwork/bin/parsemail.sh +++ b/patchwork/bin/parsemail.sh @@ -19,20 +19,20 @@ # 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 -- 2.47.3