mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00

### Goals * Make callable aliases transparent. * Catch errors in callable aliases and show the name of the source. * Show additional attributes: thredable, capturable. * Closes #5266 ## Exception ### Before ```xsh aliases['cd'] # <function xonsh.dirstack.cd> aliases['trace'] # <function xonsh.aliases.trace> aliases['null'] = lambda: 1/0 null # ZeroDivisionError: division by zero @aliases.register('catch') @aliases.register('me') @aliases.register('if') @aliases.register('you') @aliases.register('can') def _exc(args, stdin, stdout): for line in stdin.readlines(): print(line.strip() + '!', file=stdout, flush=True) return 1/0 if 'i' in $__ALIAS_NAME else 0 echo hey | catch | me | if | you | can # ZeroDivisionError: division by zero <--- ??? # hey!!!!! ``` ### After ```xsh aliases['cd'] # FuncAlias({'name': 'cd', 'func': 'cd'}) aliases['trace'] # FuncAlias({'name': 'trace', 'func': 'trace', '__xonsh_threadable__': False}) $XONSH_SHOW_TRACEBACK=False $RAISE_SUBPROC_ERROR = False aliases['null'] = lambda: 1/0 null #Exception in thread {'cls': 'ProcProxyThread', 'name': 'Thread-15', 'func': FuncAlias({'name': 'null', 'func': '<lambda>'}), 'alias': 'null', 'pid': None} #ZeroDivisionError: division by zero @aliases.register('catch') @aliases.register('me') @aliases.register('if') @aliases.register('you') @aliases.register('can') def _exc(args, stdin, stdout): for line in stdin.readlines(): print(line.strip() + '!', file=stdout, flush=True) return 1/0 if 'i' in $__ALIAS_NAME else 0 echo hey | catch | me | if | you | can # Exception in thread {'cls': 'ProcProxyThread', 'name': 'Thread-8', 'func': FuncAlias({'name': 'if', 'func': '_exc'}), 'alias': 'if', 'pid': None} # ZeroDivisionError: division by zero # hey!!!!! ``` ## Superhelp ### Before ```xsh @aliases.register("hello") def _alias_hello(): """Show world.""" print('world') hello? # No manual entry for hello ``` ### After ```xsh @aliases.register("hello") def _alias_hello(): """Show world.""" print('world') hello? # FuncAlias({'name': 'hello', 'func': '_alias_hello'}): # Show world. ``` ## For community ⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍 comment** --------- Co-authored-by: a <1@1.1> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
24 lines
318 B
ReStructuredText
24 lines
318 B
ReStructuredText
**Added:**
|
|
|
|
* Added FuncAlias to process callable aliases.
|
|
* Added alias name printing in case of exception in alias.
|
|
|
|
**Changed:**
|
|
|
|
* <news item>
|
|
|
|
**Deprecated:**
|
|
|
|
* <news item>
|
|
|
|
**Removed:**
|
|
|
|
* <news item>
|
|
|
|
**Fixed:**
|
|
|
|
* Fixed showing alias description using superhelp e.g. ``which?``.
|
|
|
|
**Security:**
|
|
|
|
* <news item>
|