From patchwork Mon Jan 30 23:01:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 721753 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vC4fc73P9z9sf9 for ; Tue, 31 Jan 2017 10:02:32 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="WdZm9r9F"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vC4fc1CWpzDq96 for ; Tue, 31 Jan 2017 10:02:32 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="WdZm9r9F"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from nov-007-i667.relay.mailchannels.net (nov-007-i667.relay.mailchannels.net [46.232.183.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3vC4f60V6nzDq5f for ; Tue, 31 Jan 2017 10:02:05 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="WdZm9r9F"; dkim-atps=neutral X-Sender-Id: mxroute|x-authuser|stephen@that.guru Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 4D7861818DE; Mon, 30 Jan 2017 23:02:00 +0000 (UTC) Received: from one.mxroute.com (unknown [100.96.11.114]) by relay.mailchannels.net (Postfix) with ESMTPA id D07D918151F; Mon, 30 Jan 2017 23:01:59 +0000 (UTC) X-Sender-Id: mxroute|x-authuser|stephen@that.guru Received: from one.mxroute.com ([UNAVAILABLE]. [172.20.125.168]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.7.14); Mon, 30 Jan 2017 23:02:00 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: mxroute|x-authuser|stephen@that.guru X-MailChannels-Auth-Id: mxroute X-MC-Loop-Signature: 1485817320126:2444425902 X-MC-Ingress-Time: 1485817320126 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=4+OKB6F09o00cYvcGD8XzIsLIMo/Syae0Jo4hdZEAPk=; b=WdZm9r9FdgW/Nxb/n1SwHsKuIW QRBukZNoWpaDfXMxWRgwFNv6D60IN1v15jUYgWs/mY9NlT+OmcRXpqUG0ogE7ti9E9UHceQqZ/+Ad P4hPnWEitaKOw4WScAz1VrL5R2YmgJi0maCPsGFst4ka9TvyO90Lx6sD2Mp72rhAvS49JUB8B6F8o vkrjIAUIG+5RAU/Nq8MUA+LNgpHthmfLUyO/0ldRk6TpQBrq3fxpF5a0DKdNNvz0NyRkcQZ+1sbeK 8U+vSXMx+bElq5ts0C6GBqqCryPkV9UXzPRS3f59tXmGZdsFJeDA+Ep5VWKwW137LeXp1GlG5kiqH XDV6jbJQ==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 2/4] bin: Run scripts through shellcheck Date: Mon, 30 Jan 2017 23:01:43 +0000 Message-Id: <20170130230145.14983-2-stephen@that.guru> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170130230145.14983-1-stephen@that.guru> References: <20170130230145.14983-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" This mostly results in the addition of quotes to prevent globbing. Signed-off-by: Stephen Finucane --- 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 c94655b..bee047e 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 1ddad7f..a742f60 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