@@ -632,7 +632,7 @@ def perror(self, err: Union[str, Exception], traceback_war: bool=True, err_color
632632 err_msg = err_color + err_msg + Fore .RESET
633633 self .decolorized_write (sys .stderr , err_msg )
634634
635- if traceback_war :
635+ if traceback_war and not self . debug :
636636 war = "To enable full traceback, run the following command: 'set debug true'\n "
637637 war = war_color + war + Fore .RESET
638638 self .decolorized_write (sys .stderr , war )
@@ -1893,6 +1893,8 @@ def _redirect_output(self, statement: Statement) -> None:
18931893 try :
18941894 self .pipe_proc = subprocess .Popen (statement .pipe_to , stdin = subproc_stdin )
18951895 except Exception as ex :
1896+ self .perror ('Not piping because - {}' .format (ex ), traceback_war = False )
1897+
18961898 # Restore stdout to what it was and close the pipe
18971899 self .stdout .close ()
18981900 subproc_stdin .close ()
@@ -1901,8 +1903,6 @@ def _redirect_output(self, statement: Statement) -> None:
19011903 self .kept_state = None
19021904 self .redirecting = False
19031905
1904- # Re-raise the exception
1905- raise ex
19061906 elif statement .output :
19071907 import tempfile
19081908 if (not statement .output_to ) and (not self .can_clip ):
@@ -1920,7 +1920,7 @@ def _redirect_output(self, statement: Statement) -> None:
19201920 try :
19211921 sys .stdout = self .stdout = open (statement .output_to , mode )
19221922 except OSError as ex :
1923- self .perror ('Not Redirecting because - {}' .format (ex ), traceback_war = False )
1923+ self .perror ('Not redirecting because - {}' .format (ex ), traceback_war = False )
19241924 self .redirecting = False
19251925 else :
19261926 # going to a paste buffer
@@ -2007,8 +2007,10 @@ def onecmd(self, statement: Union[Statement, str]) -> bool:
20072007 stop = func (statement )
20082008
20092009 else :
2010- self .default (statement )
2011- stop = False
2010+ stop = self .default (statement )
2011+
2012+ if stop is None :
2013+ stop = False
20122014
20132015 return stop
20142016
@@ -2056,19 +2058,18 @@ def _run_macro(self, statement: Statement) -> bool:
20562058 # Run the resolved command
20572059 return self .onecmd_plus_hooks (resolved )
20582060
2059- def default (self , statement : Statement ) -> None :
2061+ def default (self , statement : Statement ) -> Optional [ bool ] :
20602062 """Executed when the command given isn't a recognized command implemented by a do_* method.
20612063
20622064 :param statement: Statement object with parsed input
20632065 """
20642066 if self .default_to_shell :
2065- result = os .system (statement .command_and_args )
2066- # If os.system() succeeded, then don't print warning about unknown command
2067- if not result :
2068- return
2067+ if 'shell' not in self .exclude_from_history :
2068+ self .history .append (statement .raw )
20692069
2070- # Print out a message stating this is an unknown command
2071- self .poutput ('*** Unknown syntax: {}\n ' .format (statement .command_and_args ))
2070+ return self .do_shell (statement .command_and_args )
2071+ else :
2072+ self .poutput ('*** {} is not a recognized command, alias, or macro\n ' .format (statement .command ))
20722073
20732074 def pseudo_raw_input (self , prompt : str ) -> str :
20742075 """Began life as a copy of cmd's cmdloop; like raw_input but
@@ -2803,7 +2804,7 @@ def show(self, args: argparse.Namespace, parameter: str='') -> None:
28032804 :param args: argparse parsed arguments from the set command
28042805 :param parameter: optional search parameter
28052806 """
2806- param = parameter .strip (). lower ( )
2807+ param = utils . norm_fold ( parameter .strip ())
28072808 result = {}
28082809 maxlen = 0
28092810
@@ -2844,7 +2845,7 @@ def do_set(self, args: argparse.Namespace) -> None:
28442845 # Check if param was passed in
28452846 if not args .param :
28462847 return self .show (args )
2847- param = args .param .strip (). lower ( )
2848+ param = utils . norm_fold ( args .param .strip ())
28482849
28492850 # Check if value was passed in
28502851 if not args .value :
@@ -3156,15 +3157,19 @@ def load_ipy(app):
31563157 history_parser_group .add_argument ('-e' , '--edit' , action = 'store_true' ,
31573158 help = 'edit and then run selected history items' )
31583159 history_parser_group .add_argument ('-s' , '--script' , action = 'store_true' , help = 'output commands in script format' )
3159- history_parser_group .add_argument ('-o' , '--output-file' , metavar = 'FILE' , help = 'output commands to a script file' )
3160- history_parser_group .add_argument ('-t' , '--transcript' , help = 'output commands and results to a transcript file' )
3160+ setattr (history_parser_group .add_argument ('-o' , '--output-file' , metavar = 'FILE' ,
3161+ help = 'output commands to a script file' ),
3162+ ACTION_ARG_CHOICES , ('path_complete' ,))
3163+ setattr (history_parser_group .add_argument ('-t' , '--transcript' ,
3164+ help = 'output commands and results to a transcript file' ),
3165+ ACTION_ARG_CHOICES , ('path_complete' ,))
31613166 history_parser_group .add_argument ('-c' , '--clear' , action = "store_true" , help = 'clear all history' )
3162- _history_arg_help = """ empty all history items
3163- a one history item by number
3164- a..b, a:b, a:, ..b items by indices (inclusive)
3165- [ string] items containing string
3166- /regex/ items matching regular expression"""
3167- history_parser .add_argument ('arg' , nargs = '?' , help = _history_arg_help )
3167+ history_arg_help = ( " empty all history items\n "
3168+ " a one history item by number\n "
3169+ " a..b, a:b, a:, ..b items by indices (inclusive)\n "
3170+ " string items containing string\n "
3171+ " /regex/ items matching regular expression")
3172+ history_parser .add_argument ('arg' , nargs = '?' , help = history_arg_help )
31683173
31693174 @with_argparser (history_parser )
31703175 def do_history (self , args : argparse .Namespace ) -> None :
@@ -3851,7 +3856,6 @@ def get(self, getme: Optional[Union[int, str]]=None) -> List[HistoryItem]:
38513856 end = int (end )
38523857 return self [start :end ]
38533858
3854- # noinspection PyUnresolvedReferences
38553859 getme = getme .strip ()
38563860
38573861 if getme .startswith (r'/' ) and getme .endswith (r'/' ):
@@ -3871,7 +3875,7 @@ def isin(hi):
38713875 :param hi: HistoryItem
38723876 :return: bool - True if search matches
38733877 """
3874- return getme . lower ( ) in hi . lowercase
3878+ return utils . norm_fold ( getme ) in utils . norm_fold ( hi )
38753879 return [itm for itm in self if isin (itm )]
38763880
38773881
0 commit comments