forked from extern/nushell
escape external args (#6560)
This commit is contained in:
parent
e7bf89b311
commit
5491634dda
@ -186,6 +186,20 @@ fn external_arg_with_variable_name() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn external_command_escape_args() {
|
||||||
|
Playground::setup("external failed command with semicolon", |dirs, _| {
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: dirs.test(), pipeline(
|
||||||
|
r#"
|
||||||
|
^echo "\"abcd"
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
|
assert_eq!(actual.out, r#""abcd"#);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[test]
|
#[test]
|
||||||
fn explicit_glob_windows() {
|
fn explicit_glob_windows() {
|
||||||
|
@ -331,7 +331,13 @@ pub fn parse_external_call(
|
|||||||
args.push(arg);
|
args.push(arg);
|
||||||
} else {
|
} else {
|
||||||
// Eval stage trims the quotes, so we don't have to do the same thing when parsing.
|
// Eval stage trims the quotes, so we don't have to do the same thing when parsing.
|
||||||
let contents = String::from_utf8_lossy(contents).to_string();
|
let contents = if contents.starts_with(b"\"") {
|
||||||
|
let (contents, err) = unescape_string(contents, *span);
|
||||||
|
error = error.or(err);
|
||||||
|
String::from_utf8_lossy(&contents).to_string()
|
||||||
|
} else {
|
||||||
|
String::from_utf8_lossy(contents).to_string()
|
||||||
|
};
|
||||||
|
|
||||||
args.push(Expression {
|
args.push(Expression {
|
||||||
expr: Expr::String(contents),
|
expr: Expr::String(contents),
|
||||||
|
Loading…
Reference in New Issue
Block a user