[Python-bugs-list] [ python-Bugs-461280 ] commands.getstatus does an ls?

noreply@sourceforge.net noreply@sourceforge.net
Thu, 13 Sep 2001 10:22:16 -0700


Bugs item #461280, was opened at 2001-09-13 10:22
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=461280&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Stephan A. Fiedler (sfiedler)
Assigned to: Nobody/Anonymous (nobody)
Summary: commands.getstatus does an ls?

Initial Comment:
It seems like the function commands.getstatus() should
just return the status of a shell command, rather than
interpreting its argument as a filename and doing an
"ls -ld" on it and returning the output.

I would have thought the function would be implemented
like this (based on commands.getoutput):

def getstatus(cmd):
    """Return exit status of executing cmd in a
shell."""
    return getstatusoutput(cmd)[0]


(Sorry for any line wrapping--the point is just to be
symmetrical with getoutput.)

Note also that closing a pipe can raise an exception,
even if useful output was captured from the command; it
may be convenient to put the pipe.close() in
commands.getstatusoutput() into a try block. But this
is probably an unlikely edge condition in most cases,
and I won't be sad if it doesn't happen :)

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=461280&group_id=5470