summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-01-29 20:23:38 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2018-01-29 20:23:38 -0500
commit6d1ce7ae47343251af3db9ddc6fd67f72352a9e7 (patch)
tree2c79353621f50e3b06a46e73fe7e8fc2455848ba /cmd2.py
parentddfd3d9a400ae81468e9abcc89fe690c30b7ec7f (diff)
downloadcmd2-git-6d1ce7ae47343251af3db9ddc6fd67f72352a9e7.tar.gz
Fixed issue with automated transcript generation via "history -t"
There is now a post-processing step which escapes all "/" characters which transcript testing treats as a regex escape if there isn't a "\" to esape it.
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/cmd2.py b/cmd2.py
index e77f4557..0bb21d4a 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -1913,6 +1913,13 @@ a..b, a:b, a:, ..b items by indices (inclusive)
# Set echo back to its original state
self.echo = saved_echo
+ # Post-process the file to escape un-escaped "/" regex escapes
+ with open(args.transcript, 'r') as fin:
+ data = fin.read()
+ post_processed_data = data.replace('/', '\/')
+ with open(args.transcript, 'w') as fout:
+ fout.write(post_processed_data)
+
plural = 's' if len(history) > 1 else ''
self.pfeedback('{} command{} and outputs saved to transcript file {!r}'.format(len(history), plural,
args.transcript))