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
Can we change the issue to the example that's currently broken?
Also, can you walk me through when this happens in practice? It reads like we're just trying corner cases but would be good to know that this fixes a real world issue.
@jntrnr unfortunately this issue doesn't seem to be easily fixed.
format!("`{}`", arg) and format!("'{}'", arg) are insufficient. format!("\"{}\"", arg.replace('\\', r"\\").replace('"', r#"\""#) should work, but nu -c misparses escaped double quotes as described in #5383.
@jntrnr the real world use case is that I'm using nu -c in CI for zoxide's nushell plugin. The use case is to test for syntax errors in the generated init script.
I discovered this because I was using an apostrophe in a comment, which ended up breaking CI.
Activity
fdncred commentedon Apr 13, 2022
I noticed that the error provides a hint, everything is single quotes in the error.
uasi commentedon Apr 29, 2022
Now
nu -c '# `'fails.ajeetdsouza commentedon Apr 29, 2022
@jntrnr can this be reopened?
sophiajt commentedon Apr 30, 2022
Can we change the issue to the example that's currently broken?
Also, can you walk me through when this happens in practice? It reads like we're just trying corner cases but would be good to know that this fixes a real world issue.
uasi commentedon Apr 30, 2022
This is certainly a real world issue. Currently (1fc7abc) any one-liner containing backticks will fail or misbehave.
uasi commentedon Apr 30, 2022
Also,
nu -c "#'"still fails (note the lack of the whitespace between#and').This also has real world implications as passing any argument that contains one single quote and no whitespace to a nu script will fail:
uasi commentedon Apr 30, 2022
The above issues are due to the following lines not escaping backticks in
argand not escapingargcontaining no whitespace:nushell/src/main.rs
Lines 85 to 89 in 1fc7abc
sophiajt commentedon Apr 30, 2022
@uasi - agreed, that seems like the cause.
If you have fixes, we'd happily take a PR for them.
uasi commentedon Apr 30, 2022
@jntrnr unfortunately this issue doesn't seem to be easily fixed.
format!("`{}`", arg)andformat!("'{}'", arg)are insufficient.format!("\"{}\"", arg.replace('\\', r"\\").replace('"', r#"\""#)should work, butnu -cmisparses escaped double quotes as described in #5383.sophiajt commentedon May 1, 2022
With @uasi's help, I think this is now fixed in the latest main.
ajeetdsouza commentedon May 1, 2022
@jntrnr the real world use case is that I'm using
nu -cin CI for zoxide's nushell plugin. The use case is to test for syntax errors in the generated init script.I discovered this because I was using an apostrophe in a comment, which ended up breaking CI.