From da7ef55309cc6e28e6381d72a5b375edb62fbb2f Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Sun, 20 Dec 2020 23:43:32 -0500 Subject: [PATCH] Escape parens when converting to a unix path --- script_helpers/file_ops.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/script_helpers/file_ops.sh b/script_helpers/file_ops.sh index 2d00570..776ffd4 100644 --- a/script_helpers/file_ops.sh +++ b/script_helpers/file_ops.sh @@ -35,7 +35,9 @@ unix_to_windows_path() { # Fix the drive name, e.g. c\foo becomes c:\foo ret=$(sed 's,\([a-zA-Z]*\),\1:,' <<< "$ret") fi - ret="${ret////\\}" # replace unix path with windows path + ret="${ret////\\}" # Replace Unix slashes. + ret="${ret//\\\(/\(}" # Remove backslash before (. + ret="${ret//\\\)/\)}" # Remove backslash before ). echo $ret fi } @@ -45,6 +47,8 @@ windows_to_unix_path() { ret="/${ret/:/}" # Remove drive ':'. ret="${ret//\\//}" # Replace Windows slashes. ret="${ret// /\\ }" # Add a backslash before spaces. + ret="${ret//\(/\\(}" # Add a backslash before (. + ret="${ret//\)/\\)}" # Add a backslash before ). echo "$ret" }