amoffat/pbs — Issue #2: Incorrect treatment of arguments with values
Author: mapio
Created: 2012-01-16 09:32:17+00:00
State: open

First, thank you for the code: it's really handy.

I'm experimenting with it but I found a problem with (short) arguments that have a value. For instance, to run

ls -l | cut -f 1 - d " "

with pbs I did

cut(ls('-l'),'-f 1', '-d " " ')

that yield an exception complaining about cut -d parameter that should be a single character. I guess the problem is that in your Popen you pass an array containing '-d " "' instead of two values '-d' and ' ' (as you should). I think that parsing arguments can be done with shlex, but I'm too lazy to investigate it further.

My fix is to replace the first two parameter of the Popen call with

' '.join(cmd), shell=True

and let the Popen do the magic. I'm not forking and asking you to pull such "fix" because I'm not sure it is in line with the treatment of args (long and short) you have in mind.

Hope this helps,
Massimo

P.S.
Your example shows also a bug, if I run

curl("http://duckduckgo.com/", "-o page.html", silent=True)

a file named ' page.html' gets created in the wd (notice the space in front of the name) that I guess is not the intended outcome.