You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
scripts do not take arguments as in the REPL #9766
status:needs-triageAn issue that hasn't had any proper lookusage:script-fileIssues related to executing a script file (as opposed to a module or sourcing)
Error: nu::parser::unknown_flag
× The `main` command doesn't have flag `-a`.
╭─[<commandline>:1:1]
1 │ main -a 123 -b 456 -c 789
· ┬
· ╰── unknown flag
╰────
help: Available flags: --help(-h). Use `--help` for more information.
works fine in the REPL but the exact same command in a script fails.
it looks like the quotes are removed when passing the arguments to the script, but "-a" is a string, not an invalid option -a.
I think this is working as intended since the quotes aren't part of the literal string value which are passed to the child nu process. There's no way for the child nu (or any external command) process to disambiguate between whether the caller used quotes or not. def --wrapped seems to be a sufficient workaround for this. I'm going to close this, if you disagree we can re-open.
status:needs-triageAn issue that hasn't had any proper lookusage:script-fileIssues related to executing a script file (as opposed to a module or sourcing)
Activity
amtoine commentedon Jul 28, 2023
it appears writting
solves the issue 😮
mengsuenyan commentedon Jul 29, 2023
the main function just like the normal custom command,
file: foo.nu
export def main [ --a (-a): number, --b (-b): number, --c (-c): number, ] { $a + $b + $c }amtoine commentedon Jul 29, 2023
@mengsuenyan
yes, your example works fine but i do not think it solves this issue 😕
we can see that
works fine in the REPL but the exact same command in a script fails.
it looks like the quotes are removed when passing the arguments to the script, but
"-a"is a string, not an invalid option-a.132ikl commentedon Feb 28, 2025
I think this is working as intended since the quotes aren't part of the literal string value which are passed to the child
nuprocess. There's no way for the childnu(or any external command) process to disambiguate between whether the caller used quotes or not.def --wrappedseems to be a sufficient workaround for this. I'm going to close this, if you disagree we can re-open.