Conversation
|
The first casualty. /cc @jntrnr At the end of this script it calls several custom commands. I think they should all still print output but only the last one does. This is how the end of the script looks Fixed by changing the last lines to this: |
|
2nd casualty. turtle.nu The script Fixed by changing the end part to this |
|
And 3rd - my poor friend gradient.nu. The prime benchmark that started the craze. I'm not sure what to do with gradient.nu because it wants to draw each row at a time. I actually would rather continually output on all the scripts versus collecting everything at the end. I don't think that's a good solution. We should be able to output iteratively. Now that I think about it. I have some progress bar scripts that probably won't work either now. |
|
@fdncred - what is Can you try this too: If you don't see both, I think we don't have it, yet. |
This one is correct now and needs |
|
@jntrnr I did this on and this on 256_color_testpattern and it works too and I changed thie one line in new line |
# Description Have `print` print it's input, so it's easier to print a pipeline (esp after we land #8292 and related) # User-Facing Changes `print` will now print its input, if there are no args given # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8292 +/- ##
==========================================
- Coverage 68.05% 67.96% -0.10%
==========================================
Files 621 621
Lines 99938 99923 -15
==========================================
- Hits 68015 67911 -104
- Misses 31923 32012 +89
|
|
Fixed everything except this python-virtualenv tests. Can't quite figure out what the problem is there. Output is not helpfull at all |
Identified problem. To test prompt that shell is behaving correctly virtualenv tests is running a script created like this: def _get_test_lines(self, activate_script):
commands = [
self.print_python_exe(),
self.print_os_env_var("VIRTUAL_ENV"),
self.activate_call(activate_script),
self.print_python_exe(),
self.print_os_env_var("VIRTUAL_ENV"),
self.print_prompt(),
# \\ loads documentation from the virtualenv site packages
self.pydoc_call,
self.deactivate,
self.print_python_exe(),
self.print_os_env_var("VIRTUAL_ENV"),
"", # just finish with an empty new line
]
return commandsWhich results in following nushell script: The problem here is that everything is printing to stdout except def print_prompt(self):
return r"print $env.VIRTUAL_PROMPT"to print that output. I think I will need to PR to virtualenv repository to resolve this issue. |
|
I haven't followed this PR in detail, but you can make PR to virtualenv. Regardless of this PR getting merged or not, adding I personally support not auto-printing intermediate pipelines, only the last one. Btw, what happens if you have nested blocks? Like |
|
Cool, to me, this behavior seems good 👍 For the virtualenv PR, you'll need to add a changelog entry as well. You can check previous PRs in the virtualenv repo done by me, or one open just now by WindSoilder, for reference. |
|
I think we're ready to try again with this PR. Can you fix the conflicts and then we'll let CI run again and see if it goes through. |
Done. I think it is ready for merge |
This is related to nushell#8292.



Description
Change behavior of block evaluation to not print result of intermediate commands.



Previously result of every but last pipeline in a block was printed to stdout, and last one was returned
With this change results of intermediate pipelines are discarded after they finish and the last one is returned as before:
Now one should use
printexplicitly to print something to stdoutNote, that this behavior is not limited to functions! The scope of this change are all blocks. All of the below are executed as blocks and thus exibited this behavior in the same way:

With this change outputs for all types of blocks are cleaned:

User-Facing Changes
All types of blocks (function bodies, closures,
ifbranches,forandloopbodies e.t.c.) no longer print result of intermediate pipelines.Tests + Formatting
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --checkto check standard code formatting (cargo fmt --allapplies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collectto check that you're using the standard code stylecargo test --workspaceto check that all tests passAfter Submitting
If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.