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

noreply@sourceforge.net noreply@sourceforge.net
Thu, 13 Sep 2001 12:02:54 -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: Not a Bug
>Status: Closed
>Resolution: Rejected
Priority: 2
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 :)

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

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-09-13 12:02

Message:
Logged In: YES 
user_id=6380

Check the library reference manual. Despite what the name
may suggest to you, this is exactly how the function is
defined. Whether that's useful or not is irrelevant -- this
is what it is supposed to do.

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

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