@@ -3428,7 +3428,7 @@ def do_history(self, args: argparse.Namespace) -> Optional[bool]:
34283428 except Exception as e :
34293429 self .perror ('Saving {!r} - {}' .format (args .output_file , e ), traceback_war = False )
34303430 elif args .transcript :
3431- return self ._generate_transcript (history , args .transcript )
3431+ self ._generate_transcript (history , args .transcript )
34323432 else :
34333433 # Display the history items retrieved
34343434 for hi in history :
@@ -3507,10 +3507,9 @@ def _persist_history(self):
35073507 msg = "can not write persistent history file '{}': {}"
35083508 self .perror (msg .format (self .persistent_history_file , ex ), traceback_war = False )
35093509
3510- def _generate_transcript (self , history : List [Union [HistoryItem , str ]], transcript_file : str ) -> Optional [ bool ] :
3510+ def _generate_transcript (self , history : List [Union [HistoryItem , str ]], transcript_file : str ) -> None :
35113511 """
35123512 Generate a transcript file from a given history of commands
3513- :return: True if running of commands should stop
35143513 """
35153514 # Validate the transcript file path to make sure directory exists and write access is available
35163515 transcript_path = os .path .abspath (os .path .expanduser (transcript_file ))
@@ -3521,7 +3520,6 @@ def _generate_transcript(self, history: List[Union[HistoryItem, str]], transcrip
35213520 return
35223521
35233522 commands_run = 0
3524- stop = False
35253523 try :
35263524 with self .sigint_protection :
35273525 # Disable echo while we manually redirect stdout to a StringIO buffer
@@ -3573,6 +3571,11 @@ def _generate_transcript(self, history: List[Union[HistoryItem, str]], transcrip
35733571 self .echo = saved_echo
35743572 self .stdout = saved_stdout
35753573
3574+ # Check if all commands ran
3575+ if commands_run < len (history ):
3576+ warning = "Command {} triggered a stop and ended transcript generation early" .format (commands_run )
3577+ self .perror (warning , err_color = constants .WARNING_COLOR , traceback_war = False )
3578+
35763579 # finally, we can write the transcript out to the file
35773580 try :
35783581 with open (transcript_file , 'w' ) as fout :
@@ -3588,8 +3591,6 @@ def _generate_transcript(self, history: List[Union[HistoryItem, str]], transcrip
35883591 msg = '{} {} saved to transcript file {!r}'
35893592 self .pfeedback (msg .format (commands_run , plural , transcript_file ))
35903593
3591- return stop
3592-
35933594 edit_description = ("Edit a file in a text editor\n "
35943595 "\n "
35953596 "The editor used is determined by a settable parameter. To set it:\n "
@@ -3677,7 +3678,7 @@ def do_load(self, args: argparse.Namespace) -> Optional[bool]:
36773678 self ._script_dir .append (os .path .dirname (expanded_path ))
36783679
36793680 if args .transcript :
3680- return self ._generate_transcript (script_commands , os .path .expanduser (args .transcript ))
3681+ self ._generate_transcript (script_commands , os .path .expanduser (args .transcript ))
36813682 else :
36823683 return self .runcmds_plus_hooks (script_commands )
36833684
0 commit comments