Merge pull request #3106 from jb-leger/command_cache_env_pred

Command cache env pred
This commit is contained in:
Gil Forsyth 2019-05-15 14:58:57 -04:00 committed by GitHub
commit 61c3566a15
Failed to generate hash of commit
2 changed files with 38 additions and 0 deletions

View 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>

View file

@ -420,6 +420,19 @@ def predict_hg(args):
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():
"""Generates a new defaultdict for known threadable predictors.
The default is to predict true.
@ -435,6 +448,7 @@ def default_threadable_predictors():
"cmd": predict_shell,
"cryptop": predict_false,
"curl": predict_true,
"env": predict_env,
"ex": predict_false,
"emacsclient": predict_false,
"fish": predict_shell,