-
-
Notifications
You must be signed in to change notification settings - Fork 632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My alias-expanding sudo hangs with 0.8.1 #2893
Comments
Thanks for reporting @t184256! Actually, on 0.8.0, I am getting I think that the main issue here is that stdout in the alias isn't be redirected correctly. |
I think this is the right way to write such an alias: def sudo_expanding_aliases(args, stdin=None, stdout=None):
p = !(/usr/bin/env sudo @(aliases.eval_alias(args)))
for line in p:
stdout.write(line)
return p.returncode
aliases['sudo'] = sudo_expanding_aliases
del sudo_expanding_aliases |
We should probably have sudo, env and a few others always expand aliases too, though. |
I've tried your suggestion way and it doesn't play nice with interactive commands like vi. Went back to #2618 (comment) |
Let us know if there is anything specific we can do |
I am very sorry, I don't know how to put it into a specific request. Honestly, I want Currently my version hangs hard on my example, while your version hangs on any interactive command, alias or not, displaying a lone Is anything I can do to provide more info on this? Could you fix my version? What do others use? |
Yeah, I am honstely pretty confused about what is going on here |
Does 0.8.10 alias work bring anything new to the table? |
It probably does, but I haven't had a chance to look at this issue specifically. |
This comment was marked as outdated.
This comment was marked as outdated.
I've taken a short look into this.
aliases['sudo'] = 'sudo @(aliases.eval_alias($args))' # ExecAlias
sudo ls | less
# no response
UPD: this is my old try to solve this and it's mostly outdated but I leave it here for education of a stranger who digging here. I tried to solve this issue by manipulating with predictors. This alias is working with piping into capturable tools like from xonsh.commands_cache import predict_false, predict_true
def sudo_expanding_aliases(cmd, stdin=None, stdout=None, stderr=None):
curr_sudo_predictor = __xonsh__.commands_cache.threadable_predictors['sudo']
try:
__xonsh__.commands_cache.threadable_predictors['sudo'] = predict_true
if r := ![sudo echo -n]: # to get password prompt in uncapturable mode
if __xonsh__.commands_cache.predict_threadable(cmd):
__xonsh__.commands_cache.threadable_predictors['sudo'] = predict_true
p = !(sudo @(aliases.eval_alias(cmd)))
p.end()
for line in p:
stdout.write(line)
if p.errors:
for line in p.errors.splitlines():
stderr.write(line + '\n')
__xonsh__.commands_cache.threadable_predictors['sudo'] = curr_sudo_predictor
return p.returncode
else:
__xonsh__.commands_cache.threadable_predictors['sudo'] = predict_false
r = ![sudo @(aliases.eval_alias(cmd))]
__xonsh__.commands_cache.threadable_predictors['sudo'] = curr_sudo_predictor
return r.rtn
finally:
__xonsh__.commands_cache.threadable_predictors['sudo'] = curr_sudo_predictor
aliases['sudo'] = sudo_expanding_aliases
del sudo_expanding_aliases
sudo ls / | grep bin
# bin
# sbin But this alias is not working with uncapturable tools like |
I'm going to close this as duplicate #2618 |
In xonsh 0.8.1 with
--no-rc
I can dosudo ls | less
and it works fine.With a .xonshrc consisting of the following lines only:
/usr/bin/env sudo ls | less
works as expected, whilesudo ls | less
hangs hard since 0.8.1,C-C
orC-\
do not help.Couldn't find any relevant recent changes at the first glance, were there any?
The text was updated successfully, but these errors were encountered: