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
String script args with parenthesis are mangled #10908
A:quoting-expansionIssues related to string quoting, interpolation, and expansion of variable or glob patternscategory:bugSomething isn't workingusage:script-fileIssues related to executing a script file (as opposed to a module or sourcing)
./echo.nu "hi"# output: hi
./echo.nu "hi(1)"# output: hi1
Expected behavior
./echo.nu "hi(1)"
# output: hi(1)
Screenshots
No response
Configuration
key
value
version
0.86.0
branch
commit_hash
build_os
linux-x86_64
build_target
x86_64-unknown-linux-gnu
rust_version
rustc 1.72.1 (d5c2e9c34 2023-09-13) (Homebrew)
cargo_version
cargo 1.72.1
build_time
2023-10-17 17:08:20 +00:00
build_rust_channel
release
allocator
mimalloc
features
dataframe, default, sqlite, trash, which, zip
installed_plugins
Additional context
I noticed this when my browser downloaded a file twice, and it added the (1) to the end of the file name just before the extension. i.e. the_file(1).log was mangled into the_file1.log. Passing this file path to a script caused the script to fail because the_file1.log doesn't exist.
I experimented with it and interestingly ./echo.nu "hi (1)" works as expected. The difference between calling it directly and in a script from what I see if that the variable is put on stack in the second case and on stack it's already without parentheses. I think it's the way arguments are parsed somewhere in low level code but so far I haven't identified where is the logic that needs to be fixed. And also that's a change which can break some things potentially.
I think I found where things go wrong. Before entering parse_string "1232 (1)" (with space) is implicitly transformed to `1232 (1)` which is considered just string and works fine. The version without space has quotation marks stripped and is just 1232(1) which is parsed as StringInterpolation. The only thing I don't know yet is where does the implicit transformation happen but I spent enough time today on this. Also I'm not sure if StringInterpolation parsing is broken or the conversion shouldn't take place.
I finally found it, it's an issue with deparser which should add backticks to non string interpolation values with brackets. I'll post a PR for it soon.
A:quoting-expansionIssues related to string quoting, interpolation, and expansion of variable or glob patternscategory:bugSomething isn't workingusage:script-fileIssues related to executing a script file (as opposed to a module or sourcing)
Activity
amtoine commentedon Nov 1, 2023
good catch @pcrock-thmdo
i couldn't reproduce this in the REPL nor as a module, so i'd say it's an issue with Nushell scripts, not custom commands or modules 👌
MarikaChlebowska commentedon Nov 5, 2023
I experimented with it and interestingly
./echo.nu "hi (1)"works as expected. The difference between calling it directly and in a script from what I see if that the variable is put on stack in the second case and on stack it's already without parentheses. I think it's the way arguments are parsed somewhere in low level code but so far I haven't identified where is the logic that needs to be fixed. And also that's a change which can break some things potentially.MarikaChlebowska commentedon Nov 5, 2023
I think I found where things go wrong. Before entering
parse_string"1232 (1)" (with space) is implicitly transformed to `1232 (1)` which is considered just string and works fine. The version without space has quotation marks stripped and is just 1232(1) which is parsed as StringInterpolation. The only thing I don't know yet is where does the implicit transformation happen but I spent enough time today on this. Also I'm not sure if StringInterpolation parsing is broken or the conversion shouldn't take place.MarikaChlebowska commentedon Nov 11, 2023
I finally found it, it's an issue with deparser which should add backticks to non string interpolation values with brackets. I'll post a PR for it soon.
Fix parsing of strings with special characters (#11030)
Fix parsing of strings with special characters (nushell#11030)