amoffat / sh

Python process launching

Home Page:https://sh.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

documentation has bad example code

oren-hecht opened this issue · comments

In the "Exit Codes and Exceptions" section of the documentation -https://github.com/amoffat/sh/blob/develop/docs/source/sections/exit_codes.rst#exit-codes--exceptions

there is the first example code

output = ls("/")
print(output.exit_code) # should be 0

This code does not work as described - when run in the terminal it returns an exception. It seems the way to make it work as described is -

ls("/", _return_cmd=True)
print(output.exit_code) # should be 0

this seems to include a larger issue, where the object returns is a string instead of a RunningComand object.. a fix for this may also be planned, but for now maybe consider fixing the docs?

image

Thanks for the report!

This was the only instance in the docs that needed fixing, AFAICS.

Commands return strings by default since sh 2.0.0, so only the docs needed fixing.