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
Simplify string interpolation #3401
Conversation
is this supposed to work?
i get this
or perhaps this
|
In the first one you're echoing a block. In the second one you're echoing a variable that's not in scope. We could explore expanding |
I was trying to mimic what you listed in the PR description:
Does something like that still work? If so, what is the syntax? |
@fdncred that's removed now. The bottom text talks about this: "The block is assume to be a full Nushell block, and I suspect this will mean the column shorthand behavior will be removed. Instead, you'll need to use the format command." So you'd need to use |
What about echo "this is my $name" and for chained variable accesses echo "this is my os ${nu.env.OS}" and for command calls echo "hello $(echo world)" I feel like interpolation would be a more common use case than literal dollar signs, and for that, perhaps backticks could be repurposed to signify string literals. This would also allow users to use both single and double quotes in a string, e.g.
Command substitution could be used in cases where the user wants both string literals and interpolation, e.g. I feel like this would be a bit more natural for users coming from other shells, but I'm happy to hear your thoughts. |
I'd really prefer to be consistent with how we handle this. I would push back on, "when it looks like |
That's a good point. I was thinking of revising my comment to:
for consistency, but looking at it, I think JT's syntax looks cleaner. 😁 |
@jmoore34 - ah good. and thanks for investigating 🙂 Looking forward to using this! |
This is a draft proposal to simplify string interpolation.
Currently, string interpolation looks like this:
It also can handle columns passed to it:
This proposal uses a different syntax and aligns the block with Nushell blocks, removing some of the surprises and streamlining the experience of using it.
Without #3389, this PR will look like:
With #3389, this PR will look like:
The block is assume to be a full Nushell block, and I suspect this will mean the column shorthand behavior will be removed. Instead, you'll need to use the
format
command.