From 90d13931377396aeac9571dd1f44384ee3c38836 Mon Sep 17 00:00:00 2001 From: Pete Goldsmith Date: Wed, 7 Sep 2022 22:15:29 +1000 Subject: [PATCH] Handle tilde in path for directory share (#233) * Expand Tilde in path * Expand tilde in disk paths --- Sources/tart/Commands/Run.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/tart/Commands/Run.swift b/Sources/tart/Commands/Run.swift index 2ec7168..233fb8e 100644 --- a/Sources/tart/Commands/Run.swift +++ b/Sources/tart/Commands/Run.swift @@ -126,8 +126,9 @@ struct Run: AsyncParsableCommand { func additionalDiskAttachments() throws -> [VZDiskImageStorageDeviceAttachment] { var result: [VZDiskImageStorageDeviceAttachment] = [] let readOnlySuffix = ":ro" + let expandedDiskPaths = disk.map { NSString(string:$0).expandingTildeInPath } - for rawDisk in disk { + for rawDisk in expandedDiskPaths { if rawDisk.hasSuffix(readOnlySuffix) { result.append(try VZDiskImageStorageDeviceAttachment( url: URL(fileURLWithPath: String(rawDisk.prefix(rawDisk.count - readOnlySuffix.count))), @@ -166,7 +167,7 @@ struct Run: AsyncParsableCommand { let (name, path) = (String(splits[0]), String(splits[1])) - result.append(DirectoryShare(name: name, path: URL(fileURLWithPath: path), readOnly: readOnly)) + result.append(DirectoryShare(name: name, path: URL(fileURLWithPath: NSString(string: path).expandingTildeInPath), readOnly: readOnly)) } return result