support redirection and pipe in the commands
fix #9 based on (and replace) #129
Things like:
- output redirection, eg:
recoverable > /tmp/a.txtbecome possible (for any other command) - piping, eg:
locate ... | grep foobartoo - and combining of piping + redirection too, eg:
help | grep z > /tmp/test.txt
The most painful part of the diff is switching from print() to return (so that Python output could be reused in subprocess.run()). Another option was to write the stdout write (intercepting print) but it sounded cumbersome.
Thank you, this seems quite interesting, although I am getting several errors. I tried to run recoverable and first got an error related to list_parts, which I fixed by changing the line to this:
yield f"Partition #{i} -> {parts[part]}"
Now I am getting an error on the redirection part. Moreover, it seems that on Windows the file paths are being mangled, e.g. try to do this:
recoverable > C:\Users\name\Desktop\test.txt
It seems that Python is reading the backslash as an escape character.