Limit when we expand external args (#668)

This commit is contained in:
JT 2022-01-05 12:09:53 +11:00 committed by GitHub
parent 41dbc641cc
commit b4c72e85e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -264,9 +264,13 @@ impl<'call> ExternalCommand<'call> {
for arg in &self.args {
let arg = trim_enclosing_quotes(arg);
let arg = nu_path::expand_path_with(arg, cwd)
.to_string_lossy()
.to_string();
let arg = if arg.starts_with('~') || arg.starts_with("..") {
nu_path::expand_path_with(arg, cwd)
.to_string_lossy()
.to_string()
} else {
arg
};
let arg = arg.replace("\\", "\\\\");