mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00
Merge pull request #3106 from jb-leger/command_cache_env_pred
Command cache env pred
This commit is contained in:
commit
61c3566a15
2 changed files with 38 additions and 0 deletions
24
news/command_cache_env_pred.rst
Normal file
24
news/command_cache_env_pred.rst
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
**Added:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Changed:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Deprecated:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Removed:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Fixed:**
|
||||||
|
|
||||||
|
* threadable predictor for 'env' command based on predictor from the executed
|
||||||
|
command. Fixes #2759 and #3103.
|
||||||
|
|
||||||
|
**Security:**
|
||||||
|
|
||||||
|
* <news item>
|
|
@ -420,6 +420,19 @@ def predict_hg(args):
|
||||||
return not ns.interactive
|
return not ns.interactive
|
||||||
|
|
||||||
|
|
||||||
|
def predict_env(args):
|
||||||
|
"""Predict if env is launching a threadable command or not.
|
||||||
|
The launched command is extracted from env args, and the predictor of
|
||||||
|
lauched command is used."""
|
||||||
|
|
||||||
|
for i in range(len(args)):
|
||||||
|
if args[i] and args[i][0] != "-" and "=" not in args[i]:
|
||||||
|
# args[i] is the command and the following is its arguments
|
||||||
|
# so args[i:] is used to predict if the command is threadable
|
||||||
|
return builtins.__xonsh__.commands_cache.predict_threadable(args[i:])
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def default_threadable_predictors():
|
def default_threadable_predictors():
|
||||||
"""Generates a new defaultdict for known threadable predictors.
|
"""Generates a new defaultdict for known threadable predictors.
|
||||||
The default is to predict true.
|
The default is to predict true.
|
||||||
|
@ -435,6 +448,7 @@ def default_threadable_predictors():
|
||||||
"cmd": predict_shell,
|
"cmd": predict_shell,
|
||||||
"cryptop": predict_false,
|
"cryptop": predict_false,
|
||||||
"curl": predict_true,
|
"curl": predict_true,
|
||||||
|
"env": predict_env,
|
||||||
"ex": predict_false,
|
"ex": predict_false,
|
||||||
"emacsclient": predict_false,
|
"emacsclient": predict_false,
|
||||||
"fish": predict_shell,
|
"fish": predict_shell,
|
||||||
|
|
Loading…
Add table
Reference in a new issue