-
-
Notifications
You must be signed in to change notification settings - Fork 673
procs: Add $XONSH_CAPTURE_ALWAYS variable for opt-in interactive capt… #4283
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
procs: Add $XONSH_CAPTURE_ALWAYS variable for opt-in interactive capt… #4283
Conversation
Nice start. We have this on the current master: $XONSH_TRACE_SUBPROC=True
echo 1
# TRACE SUBPROC: (['echo', '1'],), captured=hiddenobject
_ = $(echo 1)
# TRACE SUBPROC: (['echo', '1'],), captured=stdout
_ = !(echo 1)
# TRACE SUBPROC: (['echo', '1'],), captured=object
![echo 1]
# TRACE SUBPROC: (['echo', '1'],), captured=hiddenobject
$[echo 1]
# TRACE SUBPROC: (['echo', '1'],), captured=False And we want to switch first case to By the proposed changes:
we will change also |
Also I think this setting should be in |
When running commands in xonsh they are actually transformed into |
Yep, and I think we should have the way to switch this transformation to I suggest for example |
Why? That way you can't know the return value and other info.
|
Another current issue is that when |
Yep, maybe it should (have to) be cd /tmp
# download interactive tool i.e. Miniconda from https://docs.conda.io/en/latest/miniconda.html
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh
![./Miniconda3-latest-Linux-x86_64.sh ]
# press Enter and got freezed shell
$[./Miniconda3-latest-Linux-x86_64.sh ]
# working as expected It looks like we should have another operator that can run uncaptured command but can catch return code etc. As I understand we want to solve this case. We want to run just: ./Miniconda3-latest-Linux-x86_64.sh
# or the same case is #4243:
git log and save the return code and timing to the history. For now these cases are failed because captured is the default. |
Subproc has stdout/stderr and return code. Sometimes we want to catch both. Sometimes only return code. Sometimes nothing. Is the current operators/run_subproc functionality enough? |
That's exactly what XONSH_CAPTURE_ALWAYS is for. No need for a different operator. |
I've tested the branch and it works for me! |
xonsh/procs/specs.py
Outdated
@@ -857,8 +857,15 @@ def run_subproc(cmds, captured=False, envs=None): | |||
if builtins.__xonsh__.env.get("XONSH_TRACE_SUBPROC"): | |||
print(f"TRACE SUBPROC: {cmds}, captured={captured}", file=sys.stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put the actual captured
value here.
We lose the use case like: # current master
r = ![ls] # the tool that produce some output
if 'file' in r.out: # searching in the output
print('found file') In this case |
So this is the case to turn on XONSH_CAPTURE_OUTPUT
I wonder why that is.. this is really strange! (just to be clear it also happens on main) |
f06c412
to
254d907
Compare
254d907
to
25f73a0
Compare
Codecov Report
@@ Coverage Diff @@
## main #4283 +/- ##
==========================================
- Coverage 57.18% 57.12% -0.06%
==========================================
Files 138 138
Lines 22151 22152 +1
Branches 4059 4059
==========================================
- Hits 12666 12655 -11
- Misses 8438 8444 +6
- Partials 1047 1053 +6
Continue to review full report at Codecov.
|
See xonsh/xonsh#3263, fix coming in xonsh/xonsh#4283
See this previous commit: 90c0690 xonsh: workaround issue with git commit Also see xonsh/xonsh#4283, which should make this workaround unnecessary.
Thanks @anki-code ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I think this is a good step forward and all the functionality is still available but with a slightly friendlier default.
Thanks @daniel-shimon for this! And thanks @anki-code for your input!
The latest master commit includes a merge of xonsh/xonsh#4283, which means I can remove my workarounds for that issue.
…uring
Closes #4249
Closes #4304
Closes #4024
Closes #3672
Closes #3311
Closes #4318
Closes #3584
Closes #3672
Explanation from one of the issues:
For community
⬇️ Please click the 👍 reaction instead of leaving a
+1
or 👍 comment