There are a few problems with this code:
- It should allow absolute paths. Specifically, it should not prepend
./ to the path. It should simply leave the path alone.
- The file isn't closed.
- When you send the output to a file, LLDB includes what it would have sent to the terminal verbatim. For a color terminal, this includes ANSI escape sequences. These should be stripped from the output.
I would have created a branch and submitted a pull request, but don't have write-permission to the repo; so here's a patch.
patch.txt