Skip to content
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

allow print to take data as input again #9823

Merged
merged 3 commits into from Jul 27, 2023

Conversation

amtoine
Copy link
Member

@amtoine amtoine commented Jul 27, 2023

related to https://discord.com/channels/601130461678272522/601130461678272524/1134079115134251129

Description

before 0.83.0, print used to allow piping data into it, e.g.

"foo" | print

instead of

print "foo"

this PR enables the any -> nothing input / output type to allow this again.

i've double checked and print is essentially the following snippet

        if !args.is_empty() {
            for arg in args {
                arg.into_pipeline_data()
                    .print(engine_state, stack, no_newline, to_stderr)?;
            }
        } else if !input.is_nothing() {
            input.print(engine_state, stack, no_newline, to_stderr)?;
        }
  1. the first part is for print a b c
  2. the second part is for "foo" | print

User-Facing Changes

"foo" | print

works again

Tests + Formatting

  • 🟢 toolkit fmt
  • 🟢 toolkit clippy
  • toolkit test
  • toolkit test stdlib

After Submitting

@amtoine amtoine added the type-system Problems or features related to nushell's type system label Jul 27, 2023
@amtoine amtoine added this to the 0.83.0 Fixup milestone Jul 27, 2023
@fdncred
Copy link
Collaborator

fdncred commented Jul 27, 2023

I guess Type::Any is ok here, but it does seem weird doing 1kb | print, or any other non-string type, although it works fine. So, no objections here. Kind of surprised about this one null | print. it does nothing, i guess that's right. hehe

@amtoine
Copy link
Member Author

amtoine commented Jul 27, 2023

I guess Type::Any is ok here, but it does seem weird doing 1kb | print, or any other non-string type, although it works fine. So, no objections here. Kind of surprised about this one null | print. it does nothing, i guess that's right. hehe

yeah, i agree it's a bit strange, but it worked like that before 🤔
maybe we will want to remove that in the future 😋

@sholderbach sholderbach merged commit 8403fff into nushell:main Jul 27, 2023
19 checks passed
@amtoine amtoine deleted the fix-print-signature branch July 28, 2023 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-system Problems or features related to nushell's type system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants