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
Nushell script call nu cannot parse empty string argument #9418
An argument of a function with @string does not correctly parse empty strings when called directly via nu while it works for REPL and calling the function after source.
How to reproduce
When a script is called:
script.nu
def main [--arg: string] {
print $arg
}
from bash or nu via
nu script.nu --arg ""
it returns
× Missing flag argument.
╭─[<commandline>:1:1]
1 │ main --arg
· ───┬──
· ╰── flag missing string argument
╰────
but it works when the function is created via REPL or sourced via source.
Expected behavior
I would expect the explicit nu script.nu call to behave like the interactive version.
Screenshots
No response
Configuration
key
value
version
0.81.0
branch
commit_hash
build_os
linux-x86_64
build_target
x86_64-unknown-linux-gnu
rust_version
rustc 1.69.0 (84c898d65 2023-04-16) (built from a source tarball)
I am moving some parts of a bash script that makes heavy use of environment variables that might be unset.
I would like to handle those empty values in the nu code directly.
So the call inside of the bash script looks like: `nu script.nu --arg "$POSSIBLY_UNSET_ENV"
There are also other variables that might be empty for similar reasons.
And I prefer to not require "magic" environment variables within my nushell script although this is the current workaround :)
So I guess my TL;DR is that it would be a quality of live improvement when calling nushell from bash scripts/cli.
Activity
fdncred commentedon Jun 12, 2023
What's the use case for passing an argument with an empty string?
kai-tub commentedon Jun 12, 2023
I am moving some parts of a bash script that makes heavy use of environment variables that might be unset.
I would like to handle those empty values in the nu code directly.
So the call inside of the bash script looks like: `nu script.nu --arg "$POSSIBLY_UNSET_ENV"
There are also other variables that might be empty for similar reasons.
And I prefer to not require "magic" environment variables within my nushell script although this is the current workaround :)
So I guess my TL;DR is that it would be a quality of live improvement when calling nushell from bash scripts/cli.
fdncred commentedon Jun 12, 2023
Does this work for you? #9420
allow empty string arguments (#9420)
kai-tub commentedon Jun 30, 2023
Ah, I forgot to reply. 😞
Yes, it works exactly as how I expected it to work in v82! 🎉
Thank you!