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 assignement without parentheses #9698

Closed
amtoine opened this issue Jul 15, 2023 · 3 comments
Closed

allow assignement without parentheses #9698

amtoine opened this issue Jul 15, 2023 · 3 comments
Labels
duplicate This issue is a duplicate of another issue and will be consolidated for easier handling enhancement New feature or request syntax Changes to the grammar or syntax beyond parser bugfixes

Comments

@amtoine
Copy link
Member

amtoine commented Jul 15, 2023

related to

Note
this is mainly a note for myself not to forget about this 😌

Related problem

with #9658 and #9589, we can now not use the parentheses around pipelines to declare constants with let and varibles with mut 🥳

i think it would make sense to have the same feature for variable assignment.

Describe the solution you'd like

allow to write things like

mutable variables

mut a = ls | get name
$a = ls | where type == file | get name

and get the output of the ls | where type == file | get name inside the $a variable.

now we get the following parser error

Error: nu::parser::input_type_mismatch

  × Command does not support nothing input.
   ╭─[entry #2:1:1]
 1 │ $a = ls | where type == file | get name
   ·           ──┬──
   ·             ╰── command doesn't support nothing input
   ╰────

$env mutation

allow

$env.PATH = $env.PATH
    | split row (char esep)
    | prepend ($env.HOME | path join ".local" "bin")
    | prepend ($env.CARGO_HOME | path join "bin")
    | uniq

instead of

$env.PATH = (
    $env.PATH
        | split row (char esep)
        | prepend ($env.HOME | path join ".local" "bin")
        | prepend ($env.CARGO_HOME | path join "bin")
        | uniq
)

Describe alternatives you've considered

No response

Additional context and details

No response

@amtoine amtoine added enhancement New feature or request needs-triage An issue that hasn't had any proper look labels Jul 15, 2023
@amtoine
Copy link
Member Author

amtoine commented Sep 28, 2023

i also think allowing the same with const would make sense 👍

@amtoine amtoine changed the title allow variable assignement without parentheses allow assignement without parentheses Sep 28, 2023
@agirardeau
Copy link

agirardeau commented May 25, 2024

The docs at https://www.nushell.sh/book/configuration.html#path-configuration actually say to set $env.PATH as described in this FR, without parentheses:

$env.PATH = $env.PATH | split row (char esep)
  | append /usr/local/bin
  | append ($env.CARGO_HOME | path join bin)
  | append ($env.HOME | path join .local bin)
  | uniq # filter so the paths are unique

But adding this to my env.nu produces the same command doesn't support nothing input error as reported above. I'm on 0.93.0.

It seems like the docs need to be fixed.

@sholderbach
Copy link
Member

Closing this in favor of the more general #12956

@sholderbach sholderbach closed this as not planned Won't fix, can't repro, duplicate, stale Jul 12, 2024
@sholderbach sholderbach added duplicate This issue is a duplicate of another issue and will be consolidated for easier handling syntax Changes to the grammar or syntax beyond parser bugfixes and removed needs-triage An issue that hasn't had any proper look labels Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue is a duplicate of another issue and will be consolidated for easier handling enhancement New feature or request syntax Changes to the grammar or syntax beyond parser bugfixes
Projects
None yet
Development

No branches or pull requests

3 participants