-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Can't use a Nu script with strings starting with a number #8844
Copy link
Copy link
Closed
Milestone
Description
Describe the bug
It is now (after #8635) impossible to invoke a Nu script with an argument which is a string starting with a number.
Essentially same as #8788 but that issue was falsely closed.
How to reproduce
> cat foo.nu
#!/usr/bin/env nu
def main [s: string] {
echo $s
}
> chmod +x foo.nu
> let s = '1bar'
> ./foo.nu $s # gives the same error as below, omitted
> ./foo.nu $'"($s)"' # awful but expected to work, yet the error remains
Error: nu::parser::type_mismatch
× Type mismatch during operation.
╭─[<commandline>:1:1]
1 │ main 1bar
· ───┬──
· ╰── expected string, found number-like value (hint: use quotes or backticks)
╰────
Expected behavior
I expect at least the foo $'"($s)"' approach to work. Or even better we have #8635 reverted...
Making such functions a module should work, but not so optimal for invoking inside another script or module.
Screenshots
No response
Configuration
| key | value |
|---|---|
| version | 0.78.0 |
| branch | |
| commit_hash | |
| build_os | linux-x86_64 |
| build_target | x86_64-unknown-linux-gnu |
| rust_version | rustc 1.68.1 (8460ca823 2023-03-20) |
| rust_channel | stable-x86_64-unknown-linux-gnu |
| cargo_version | cargo 1.68.1 (115f34552 2023-02-26) |
| build_time | 2023-04-06 02:23:04 +08:00 |
| build_rust_channel | release |
| features | default, zip |
| installed_plugins | from eml, from ics, from ini, from vcf, query, query json, query web, query xml |
Additional context
By the way this could have mingled with #7936, because foo $"''($str)''" prints 1bar, not '1bar'.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels