Title: commands.getstatus does an ls?
Type: Stage:
Components: None Versions:
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, sfiedler
Priority: low Keywords:

Created on 2001-09-13 17:22 by sfiedler, last changed 2001-09-13 19:02 by gvanrossum. This issue is now closed.

Messages (2)
msg6517 - (view) Author: Stephan A. Terre (sfiedler) Date: 2001-09-13 17:22
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
    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 :)
msg6518 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2001-09-13 19:02
Logged In: YES 

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.
Date User Action Args
2001-09-13 17:22:15sfiedlercreate