diff mbox

Fix parsemail-batch.sh

Message ID 1297863124-9023-1-git-send-email-guilherme.salgado@linaro.org
State Superseded, archived
Headers show

Commit Message

Guilherme Salgado Feb. 16, 2011, 1:32 p.m. UTC
It was broken because it was using 'ls -l' as the input for the while loop,
which means the file modes, owner and times ended up together with the file
names themselves.

I also changed it to use parsemail.sh instead of parsemail.py as the former
sets the required environment variables that were being set in
parsemail-batch.sh.

Signed-off-by: Guilherme Salgado <guilherme.salgado@linaro.org>
---
 apps/patchwork/bin/parsemail-batch.sh |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

Comments

Jeremy Kerr Feb. 16, 2011, 2:38 p.m. UTC | #1
Hi Guilherme,

> It was broken because it was using 'ls -l' as the input for the while loop,
> which means the file modes, owner and times ended up together with the file
> names themselves.

That's a '1' (one), not an 'l'. Removing it will break the script.

> I also changed it to use parsemail.sh instead of parsemail.py as the former
> sets the required environment variables that were being set in
> parsemail-batch.sh.

Makes sense.

> --- a/apps/patchwork/bin/parsemail-batch.sh
> +++ b/apps/patchwork/bin/parsemail-batch.sh
> @@ -19,7 +19,7 @@
>  # along with Patchwork; if not, write to the Free Software
>  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 
> USA
> 
> -PATCHWORK_BASE="/srv/patchwork"
> +HERE=`dirname $0`

Maybe call this PATCHWORK_BINDIR, so it's a little more obvious what to 
replace this with if they move one of the scripts?

Cheers,


Jeremy
Guilherme Salgado Feb. 16, 2011, 2:58 p.m. UTC | #2
On Wed, 2011-02-16 at 22:38 +0800, Jeremy Kerr wrote:
> Hi Guilherme,
> 
> > It was broken because it was using 'ls -l' as the input for the while loop,
> > which means the file modes, owner and times ended up together with the file
> > names themselves.
> 
> That's a '1' (one), not an 'l'. Removing it will break the script.

Oops, that should teach me to copy and paste things when I'm trying to
reproduce them in a separate shell.

I actually ran the script after removing it and it didn't break, but
I'll add it back. 

> 
> > I also changed it to use parsemail.sh instead of parsemail.py as the former
> > sets the required environment variables that were being set in
> > parsemail-batch.sh.
> 
> Makes sense.
> 
> > --- a/apps/patchwork/bin/parsemail-batch.sh
> > +++ b/apps/patchwork/bin/parsemail-batch.sh
> > @@ -19,7 +19,7 @@
> >  # along with Patchwork; if not, write to the Free Software
> >  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 
> > USA
> > 
> > -PATCHWORK_BASE="/srv/patchwork"
> > +HERE=`dirname $0`
> 
> Maybe call this PATCHWORK_BINDIR, so it's a little more obvious what to 
> replace this with if they move one of the scripts?

Sure, I'll change it.

Now my question is: should I start a new thread with a v2 patch or is it
preferred that I pass this one to send-email when sending the next
version of the patch?

Cheers,
diff mbox

Patch

diff --git a/apps/patchwork/bin/parsemail-batch.sh b/apps/patchwork/bin/parsemail-batch.sh
index d786022..903bf95 100755
--- a/apps/patchwork/bin/parsemail-batch.sh
+++ b/apps/patchwork/bin/parsemail-batch.sh
@@ -19,7 +19,7 @@ 
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-PATCHWORK_BASE="/srv/patchwork"
+HERE=`dirname $0`
 
 if [ $# -ne 1 ]
 then
@@ -37,15 +37,9 @@  then
 	exit 1
 fi
 
-ls -1rt "$mail_dir" |
+ls -rt "$mail_dir" |
 while read line;
 do
 	echo $line
-	PYTHONPATH="$PATCHWORK_BASE/apps":"$PATCHWORK_BASE/lib/python" \
-		DJANGO_SETTINGS_MODULE=settings \
-		"$PATCHWORK_BASE/apps/patchwork/bin/parsemail.py" < \
-		"$mail_dir/$line"
+	$HERE/parsemail.sh < "$mail_dir/$line"
 done
-
-
-