From 537c6b3ed9a783b64bec0d41260c13ac84b7feb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E6=9D=89?= Date: Mon, 2 Dec 2019 03:23:35 +0800 Subject: fix realpath behavior in windows (#3425) --- cli/ops/fs.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'cli/ops') diff --git a/cli/ops/fs.rs b/cli/ops/fs.rs index 54ac1971b..c847931ab 100644 --- a/cli/ops/fs.rs +++ b/cli/ops/fs.rs @@ -300,7 +300,11 @@ fn op_realpath( // corresponds to the realpath on Unix and // CreateFile and GetFinalPathNameByHandle on Windows let realpath = fs::canonicalize(&path)?; - let realpath_str = realpath.to_str().unwrap().to_owned().replace("\\", "/"); + let mut realpath_str = + realpath.to_str().unwrap().to_owned().replace("\\", "/"); + if cfg!(windows) { + realpath_str = realpath_str.trim_start_matches("//?/").to_string(); + } Ok(json!(realpath_str)) }) } -- cgit v1.2.3