Skip to content

can't pass flags into function #5445

Closed
Closed

Description

@gipsyh

Describe the bug

# qemu.nu
def main [kernel: string, --version: string, --arch: string] {

}

截屏2022-05-05 09 32 07

if I recall correctly, it's ok in 0.61.1

How to reproduce

described above

Expected behavior

no error report

Screenshots

No response

Configuration

key value
version 0.62.0
branch
tag
build_os macos-aarch64
rust_version rustc 1.60.0 (7737e0b5c 2022-04-04)
rust_channel stable-aarch64-apple-darwin
cargo_version cargo 1.60.0 (d1fd9fe2c 2022-03-01)
pkg_version 0.62.0
build_time 2022-05-04 10:04:15 +08:00
build_rust_channel release
features default, trash, which, zip
installed_plugins

Additional context

No response

Activity

  1. changed the title [-]can't pass flags into main[/-] [+]can't pass flags into function[/+] on May 5, 2022
  2. added
    category:bug
    on May 5, 2022
  3. uasi commented on May 5, 2022

    @uasi
    Contributor

    We need to either

    1. fix
      args_to_script.push(escape_quote_string(&arg));
      not to quote arguments that look like flags, or
    2. make functions accept quoted strings as flags.
  4. added this to the v0.63.0 milestone on May 9, 2022
  5. gipsyh commented on May 10, 2022

    @gipsyh
    ContributorAuthor

    It still not work in my machine.
    #5447 (comment)

  6. merelymyself commented on May 10, 2022

    @merelymyself
    Contributor

    @gipsyh - my bad, I forgot to factor in cases where the function is defined with multiple flags on the same line. I usually define my functions like

    def main [
    --flag: string,
    --flag2: int,
    ]
    

    which is why I overlooked it. There's an easy fix.

  7. hustcer commented on May 11, 2022

    @hustcer
    Contributor

    Seems still not work after #5493 ?

  8. hustcer commented on May 13, 2022

    @hustcer
    Contributor

    It's found that nu b.nu linux --version v5.2 works but nu b.nu linux --version=v5.2 not work:

    @hustcer ➜ tmp git(develop) $> nu b.nu linux --version v5.2
    linux
    v5.2
    
    @hustcer ➜ tmp git(develop) $> nu b.nu linux --version=v5.2
    Error: nu::parser::extra_positional (link)
    
      × Extra positional argument.
       ╭─[<commandline>:1:1]
     1 │ main "linux" "--version=v5.2"
       ·              ────────┬───────
       ·                      ╰── extra positional argument
       ╰────
      help: Usage: main {flags} <kernel>
    
    
  9. reopened this on May 13, 2022
  10. hustcer commented on May 13, 2022

    @hustcer
    Contributor

    @gipsyh You are right, the original issue has been fixed, let's close it in favor of this one: #5532

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    category:bugdeprecated:priority

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions