forked from extern/nushell
Remove custom escaping for external args. (#2095)
Our own custom escaping unfortunately is far too simple to cover all cases. Instead, the parser will now do no transforms on the args passed to an external command, letting the process spawning library deal with doing the appropriate escaping.
This commit is contained in:
@ -512,6 +512,26 @@ fn parse_interpolated_string(
|
||||
(call, error)
|
||||
}
|
||||
|
||||
/// Parses the given argument using the shape as a guide for how to correctly parse the argument
|
||||
fn parse_external_arg(
|
||||
registry: &dyn SignatureRegistry,
|
||||
lite_arg: &Spanned<String>,
|
||||
) -> (SpannedExpression, Option<ParseError>) {
|
||||
if lite_arg.item.starts_with('$') {
|
||||
return parse_full_column_path(&lite_arg, registry);
|
||||
}
|
||||
|
||||
if lite_arg.item.starts_with('`') && lite_arg.item.len() > 1 && lite_arg.item.ends_with('`') {
|
||||
// This is an interpolated string
|
||||
parse_interpolated_string(registry, &lite_arg)
|
||||
} else {
|
||||
(
|
||||
SpannedExpression::new(Expression::string(lite_arg.item.clone()), lite_arg.span),
|
||||
None,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Parses the given argument using the shape as a guide for how to correctly parse the argument
|
||||
fn parse_arg(
|
||||
expected_type: SyntaxShape,
|
||||
@ -1237,7 +1257,7 @@ fn classify_pipeline(
|
||||
args.push(name);
|
||||
|
||||
for lite_arg in &lite_cmd.args {
|
||||
let (expr, err) = parse_arg(SyntaxShape::String, registry, lite_arg);
|
||||
let (expr, err) = parse_external_arg(registry, lite_arg);
|
||||
if error.is_none() {
|
||||
error = err;
|
||||
}
|
||||
@ -1313,7 +1333,7 @@ fn classify_pipeline(
|
||||
args.push(name);
|
||||
|
||||
for lite_arg in &lite_cmd.args {
|
||||
let (expr, err) = parse_arg(SyntaxShape::String, registry, lite_arg);
|
||||
let (expr, err) = parse_external_arg(registry, lite_arg);
|
||||
if error.is_none() {
|
||||
error = err;
|
||||
}
|
||||
|
Reference in New Issue
Block a user