Skip to content

Commit 6d1ce7a

Browse files
committed
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.
1 parent ddfd3d9 commit 6d1ce7a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cmd2.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,6 +1913,13 @@ def do_history(self, args):
19131913
# Set echo back to its original state
19141914
self.echo = saved_echo
19151915

1916+
# Post-process the file to escape un-escaped "/" regex escapes
1917+
with open(args.transcript, 'r') as fin:
1918+
data = fin.read()
1919+
post_processed_data = data.replace('/', '\/')
1920+
with open(args.transcript, 'w') as fout:
1921+
fout.write(post_processed_data)
1922+
19161923
plural = 's' if len(history) > 1 else ''
19171924
self.pfeedback('{} command{} and outputs saved to transcript file {!r}'.format(len(history), plural,
19181925
args.transcript))

0 commit comments

Comments
 (0)