conda run
adds an extra newline to the output
#11763
Labels
backlog
issue has been triaged but has not been earmarked for any upcoming release
good first issue
great for new contributors, code change is envisioned to be trivial/relatively straight-forward
plugins::run
pertains to conda-run
source::community
catch-all for issues filed by community members
type::bug
describes erroneous operation, use severity::* to classify the type
Checklist
What happened?
Running a command via
conda run
adds an extra newline (when the output is non-empty):When shell redirection is naively applied to the
conda run
command (rather than to the subcommand to be executed, though getting that right would require careful and fragile quoting if it is possible at all), this leads to the captured output having an extra blank line at the end of it. Where that captured output is to be processed by another program, this can lead to syntax errors, e.g., as seen in lh3/bwa#371.In that issue, this can be avoided by using the subcommand's
-o
option instead of redirecting output. But such options are not alway available, and users often use the familiar redirection even when the subcommand has such an option.This can be avoided with
--no-capture-output
if the user knows about that option:(base) $ conda run --no-capture-output echo hello hello (base) $
but it would be beneficial if
conda run
did not alter the output by default as well.The code in question is in conda/cli/main_run.py:
conda/conda/cli/main_run.py
Lines 39 to 44 in 606f55f
It would be a simple fix to add
…, end='', …
to theprint
calls, or, if it was preferred, to only add an extra newline if the last character of the (non-empty) output is not already a newline.Conda Info
No response
Conda Config
No response
Conda list
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: